mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00

Not keeping a reference will not result in use after free, because curl protects against it, but it will result in a memory leak, because curl_share_cleanup() will fail. We should make sure that the share handle object stays alive as long as the curl handles use it.
29 lines
634 B
PHP
29 lines
634 B
PHP
--TEST--
|
|
Basic curl_share test
|
|
--FILE--
|
|
<?php
|
|
|
|
$sh = curl_share_init();
|
|
|
|
$ch1 = curl_init();
|
|
curl_setopt($ch1, CURLOPT_URL, 'file://' . __DIR__ . '/curl_testdata1.txt');
|
|
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch1, CURLOPT_SHARE, $sh);
|
|
|
|
$ch2 = curl_init();
|
|
curl_setopt($ch2, CURLOPT_URL, 'file://' . __DIR__ . '/curl_testdata2.txt');
|
|
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch2, CURLOPT_SHARE, $sh);
|
|
|
|
// Make sure nothing bad handles if the share handle is unset early.
|
|
unset($sh);
|
|
|
|
var_dump(curl_exec($ch1));
|
|
var_dump(curl_exec($ch2));
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(6) "CURL1
|
|
"
|
|
string(6) "CURL2
|
|
"
|