Skip to content

Commit a84cc91

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix memory leak when curl_slist_append() fails
2 parents b64daf9 + b2d107d commit a84cc91

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/curl/interface.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,12 +2188,14 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
21882188
ZEND_HASH_FOREACH_VAL(ph, current) {
21892189
ZVAL_DEREF(current);
21902190
val = zval_get_tmp_string(current, &tmp_val);
2191-
slist = curl_slist_append(slist, ZSTR_VAL(val));
2191+
struct curl_slist *new_slist = curl_slist_append(slist, ZSTR_VAL(val));
21922192
zend_tmp_string_release(tmp_val);
2193-
if (!slist) {
2193+
if (!new_slist) {
2194+
curl_slist_free_all(slist);
21942195
php_error_docref(NULL, E_WARNING, "Could not build curl_slist");
21952196
return FAILURE;
21962197
}
2198+
slist = new_slist;
21972199
} ZEND_HASH_FOREACH_END();
21982200

21992201
if (slist) {

0 commit comments

Comments
 (0)