X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=src%2Fphp_http_buffer.c;fp=src%2Fphp_http_buffer.c;h=64e559a5907f0c8a051d350d3511f8863fa9a683;hp=eaebfa03e7e3e477fc97ccecd907b7b1169d716f;hb=749dbbaa0e7c5e33d27121dab0f53bda85a67339;hpb=061a30e33e42ae9332a56c26cbe15bccc9d0f61f diff --git a/src/php_http_buffer.c b/src/php_http_buffer.c index eaebfa0..64e559a 100644 --- a/src/php_http_buffer.c +++ b/src/php_http_buffer.c @@ -32,9 +32,13 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_buffer_t *buf, const char *string, size_t length) { + int free_buf = !!buf; + if ((buf = php_http_buffer_init(buf))) { if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, string, length)) { - pefree(buf, buf->pmem); + if (free_buf) { + pefree(buf, buf->pmem); + } buf = NULL; } }