From: Leigh Date: Mon, 8 Feb 2016 11:36:14 +0000 (+0000) Subject: Fixed memory leak in curl_getinfo() X-Git-Tag: php-7.0.4RC1~38^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ef57f8d5d1ca853aebbc873b6bf18dbdcc197da;p=php Fixed memory leak in curl_getinfo() The "v ? v" in the CAASTR macro caused zend_string_copy to be called twice --- diff --git a/NEWS b/NEWS index 1a18dbe4b0..6390d60529 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ PHP NEWS - CURL: . Fixed bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes while curl_multi_exec). (Laruence) + . Fixed memory leak in curl_getinfo(). (Leigh) - Fileinfo: . Fixed bug #71434 (finfo throws notice for specific python file). (Laruence) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 1cd22a8acf..8b9a756aa2 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -157,7 +157,8 @@ static void _php_curl_close(zend_resource *rsrc); #define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s) - 1, (zend_long) v); #define CAAD(s, v) add_assoc_double_ex(return_value, s, sizeof(s) - 1, (double) v); #define CAAS(s, v) add_assoc_string_ex(return_value, s, sizeof(s) - 1, (char *) (v ? v : "")); -#define CAASTR(s, v) add_assoc_str_ex(return_value, s, sizeof(s) - 1, v ? v : ZSTR_EMPTY_ALLOC()); +#define CAASTR(s, v) add_assoc_str_ex(return_value, s, sizeof(s) - 1, \ + v ? zend_string_copy(v) : ZSTR_EMPTY_ALLOC()); #define CAAZ(s, v) add_assoc_zval_ex(return_value, s, sizeof(s) -1 , (zval *) v); #if defined(PHP_WIN32) || defined(__GNUC__) @@ -3036,7 +3037,7 @@ PHP_FUNCTION(curl_getinfo) } #endif if (ch->header.str) { - CAASTR("request_header", zend_string_copy(ch->header.str)); + CAASTR("request_header", ch->header.str); } } else { switch (option) {