[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5

Weilin Du <[email protected]> Mon, 27 Jul 2026 09:50:03 +0000
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Weilin Du (LamentXU123)
Date: 2026-07-27T17:43:55+08:00

Commit: https://github.com/php/php-src/commit/176ddd8dd9c79b01292f7cdde4ea7c5256f1e4c8
Raw diff: https://github.com/php/php-src/commit/176ddd8dd9c79b01292f7cdde4ea7c5256f1e4c8.diff

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  Fix leak when cURL PREREQFUNCTION returns a type other than int (#22726)

Changed paths:
  M  ext/curl/interface.c
  M  ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt


Diff:

diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 6a8e8167b839..65c2bdadf706 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -727,6 +727,7 @@ static int curl_prereqfunction(void *clientp, char *conn_primary_ip, char *conn_
 				zend_value_error("The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT");
 			}
 		} else {
+			zval_ptr_dtor(&retval);
 			zend_type_error("The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT");
 		}
 	}
diff --git a/ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt b/ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt
index 58d01df2a886..39a1d1e3caa8 100644
--- a/ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt
+++ b/ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt
@@ -78,7 +78,7 @@ try {
 
 echo "\nTesting with invalid type\n";
 curl_setopt($ch, CURLOPT_PREREQFUNCTION, function() use ($port) {
-	return 'this should be an integer';
+	return ['this should be an integer' => random_bytes(64)];
 });
 try {
     curl_exec($ch);