Skip to content

Commit 9c443c9

Browse files
committed
Fix leak when cURL PREREQFUNCTION returns a string
The return value of the function registered with CURLOPT_PREREQFUNCTION was not cleaned up. Destroy the return value. Increase the returned string in the test so that the address sanitizer picks up the leak.
1 parent c3236b9 commit 9c443c9

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

ext/curl/interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ static int curl_prereqfunction(void *clientp, char *conn_primary_ip, char *conn_
770770
zend_value_error("The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT");
771771
}
772772
} else {
773+
zval_ptr_dtor(&retval);
773774
zend_type_error("The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT");
774775
}
775776
}

ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ try {
7777

7878
echo "\nTesting with invalid type\n";
7979
curl_setopt($ch, CURLOPT_PREREQFUNCTION, function() use ($port) {
80-
return 'this should be an integer';
80+
return str_repeat('this should be an integer', 20);
8181
});
8282
try {
8383
curl_exec($ch);

0 commit comments

Comments
 (0)