X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fphp_http_buffer.c;h=d7cfd56c33b207364083a50036cb910398889b98;hb=700883ba05724a9dd14fa6d5a2eded658cf0496c;hp=b214f1d83185db8f345d35e47ca19c02707e7526;hpb=7214e1aef4efce10bcc509d2a741acef88d28781;p=m6w6%2Fext-http diff --git a/src/php_http_buffer.c b/src/php_http_buffer.c index b214f1d..d7cfd56 100644 --- a/src/php_http_buffer.c +++ b/src/php_http_buffer.c @@ -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; } }