From: Antony Dovgal Date: Fri, 23 Feb 2007 20:50:17 +0000 (+0000) Subject: fix leak X-Git-Tag: RELEASE_1_0_1~176 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4f2b5d1df3ebcc913a80a4edb513b713be084b7;p=php fix leak no need to allocate the buffer if there was no data --- diff --git a/ext/curl/interface.c b/ext/curl/interface.c index dfeebe43e0..faba70a1dd 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -713,7 +713,9 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) case PHP_CURL_FILE: return fwrite(data, size, nmemb, t->fp); case PHP_CURL_RETURN: - smart_str_appendl(&t->buf, data, (int) length); + if (length > 0) { + smart_str_appendl(&t->buf, data, (int) length); + } break; case PHP_CURL_USER: { zval **argv[2]; @@ -852,7 +854,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx case PHP_CURL_STDOUT: /* Handle special case write when we're returning the entire transfer */ - if (ch->handlers->write->method == PHP_CURL_RETURN) { + if (ch->handlers->write->method == PHP_CURL_RETURN && length > 0) { smart_str_appendl(&ch->handlers->write->buf, data, (int) length); } else { PHPWRITE(data, length);