X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=src%2Fphp_http_buffer.c;h=d7cfd56c33b207364083a50036cb910398889b98;hp=b84bcd0cb37ac247d06b5e7b7591435c02798a67;hb=bebb37d8185572d3766b7517ae8357bcc89227f8;hpb=ab1eba311be2f8aab98eed7a6164e79d69b402b2 diff --git a/src/php_http_buffer.c b/src/php_http_buffer.c index b84bcd0..d7cfd56 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( @@ -35,9 +35,13 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex( PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex( php_http_buffer_t *buf, const char *str, size_t len) { + int free_buf = !!buf; + if ((buf = php_http_buffer_init(buf))) { if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, str, len)) { - pefree(buf, buf->pmem); + if (free_buf) { + pefree(buf, buf->pmem); + } buf = NULL; } }