X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fphp_http_buffer.c;h=64e559a5907f0c8a051d350d3511f8863fa9a683;hb=e595d8abe5b5a93e30bd7ffba6c13fad107ce08c;hp=e24a4e18baa2e4d7e7a6c8cbdbf7d7c7967fc31b;hpb=bdd6edb59194cda9e5fcb393c48ab4230fceb32a;p=m6w6%2Fext-http diff --git a/src/php_http_buffer.c b/src/php_http_buffer.c index e24a4e1..64e559a 100644 --- a/src/php_http_buffer.c +++ b/src/php_http_buffer.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include +#include "php.h" #include "php_http_buffer.h" PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t *buf, size_t chunk_size, int flags) @@ -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; } }