Skip to content

Commit d7b9b3f

Browse files
committed
Return an array instead of string to test memleak
The CURLOPT_PREREQFUNCTION leak test returned a constant string value. Under opcache optimization, SCCP/constant folding may turn this into an interned string, which is process-lifetime allocated and therefore does not reliably trigger leak detection. Use a dynamically allocated array containing random_bytes() instead. This guarantees a non-interned, refcounted return value that exercises the missing zval_ptr_dtor() path consistently under leak analyzers.
1 parent 9c443c9 commit d7b9b3f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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 str_repeat('this should be an integer', 20);
80+
return ['this should be an integer' => random_bytes(64)];
8181
});
8282
try {
8383
curl_exec($ch);

0 commit comments

Comments
 (0)