-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Open
Description
Symfony version(s) affected
Confirmed for 6.4
Description
When using form data and resources, CurlHttpClient
leaks the resource. It is likely kept alive by a CurlHandle
at that point.
How to reproduce
<?php
use Symfony\Component\HttpClient\CurlHttpClient;
require_once __DIR__ . '/vendor/autoload.php';
$client = new CurlHttpClient();
$data = fopen('php://memory', 'r+');
$canary = fopen('php://memory', 'r+');
fwrite($data, random_bytes(1024));
fwrite($canary, random_bytes(1024));
rewind($data);
rewind($canary);
$client->request('POST', 'http://127.0.0.1:8061/imports', ['body' => ['data' => $data]]);
dump(array_map(stream_get_meta_data(...), get_resources('stream')));
unset($data);
unset($canary);
dump(array_map(stream_get_meta_data(...), get_resources('stream')));
$client->reset();
dump(array_map(stream_get_meta_data(...), get_resources('stream')));
Each dump return the resource held by $data
. The resource held by $canary
is only returned by the first dump.
Do note that passing the resource as body (e.g. ['body' => $data]
) works as expected.
JReko