Skip to content

Commit b2d107d

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix memory leak when curl_slist_append() fails
2 parents 39efe8a + d9d9919 commit b2d107d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ PHP NEWS
1313
. Fixed GH-18695 (zend_ast_export() - float number is not preserved).
1414
(Oleg Efimov)
1515

16+
- Curl:
17+
. Fix memory leak when setting a list via curl_setopt fails. (nielsdos)
18+
1619
- Date:
1720
. Fix leaks with multiple calls to DatePeriod iterator current(). (nielsdos)
1821

ext/curl/interface.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,12 +2166,14 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
21662166
ZEND_HASH_FOREACH_VAL(ph, current) {
21672167
ZVAL_DEREF(current);
21682168
val = zval_get_tmp_string(current, &tmp_val);
2169-
slist = curl_slist_append(slist, ZSTR_VAL(val));
2169+
struct curl_slist *new_slist = curl_slist_append(slist, ZSTR_VAL(val));
21702170
zend_tmp_string_release(tmp_val);
2171-
if (!slist) {
2171+
if (!new_slist) {
2172+
curl_slist_free_all(slist);
21722173
php_error_docref(NULL, E_WARNING, "Could not build curl_slist");
21732174
return FAILURE;
21742175
}
2176+
slist = new_slist;
21752177
} ZEND_HASH_FOREACH_END();
21762178

21772179
if (slist) {

0 commit comments

Comments
 (0)