From 5ecb97d495f1eb6acbd410f243e10b085652dfc5 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 19 Oct 2026 08:29:30 -0400 Subject: [PATCH] ext/curl: Propagate multipart field construction errors Retain add_simple_field() errors for scalar and nested POST fields so curl_setopt(), curl_copy_handle(), and cloning reject incomplete MIME data through the existing error and cleanup paths. --- NEWS | 4 ++++ ext/curl/interface.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 0c80ffefb1b2..5779a0a0a545 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,10 @@ PHP NEWS so an in-process engine restart keeps growing the map_ptr table). (David Carlier) +- Curl: + . Fixed curl_setopt() ignoring errors while building multipart POST fields. + (Ilia Alshanetsky) + - Date: . Fixed bug GH-20503 (Assertion failure with ext/date DateInterval property hash construction). (heathdutton) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 8f82bd7f285d..5f811d090c95 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1574,14 +1574,18 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo zval *current_element; ZEND_HASH_FOREACH_VAL(HASH_OF(current), current_element) { - add_simple_field(mime, string_key, current_element); + if ((form_error = add_simple_field(mime, string_key, current_element)) != CURLE_OK && error == CURLE_OK) { + error = form_error; + } } ZEND_HASH_FOREACH_END(); zend_string_release_ex(string_key, 0); continue; } - add_simple_field(mime, string_key, current); + if ((form_error = add_simple_field(mime, string_key, current)) != CURLE_OK && error == CURLE_OK) { + error = form_error; + } zend_string_release_ex(string_key, 0); } ZEND_HASH_FOREACH_END();