Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2c5ffd

Browse files
dunglasnicolas-grekas
authored andcommitted
[HttpClient] Fix a crash when calling CurlHttpClient::__destruct()
1 parent 4056baf commit d2c5ffd

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,20 @@ public function stream($responses, float $timeout = null): ResponseStreamInterfa
301301
public function __destruct()
302302
{
303303
$this->multi->pushedResponses = [];
304-
if (\defined('CURLMOPT_PUSHFUNCTION')) {
305-
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
306-
}
307304

308-
$active = 0;
309-
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
305+
if (\is_resource($this->multi->handle)) {
306+
if (\defined('CURLMOPT_PUSHFUNCTION')) {
307+
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
308+
}
309+
310+
$active = 0;
311+
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
312+
}
310313

311314
foreach ($this->multi->openHandles as [$ch]) {
312-
curl_setopt($ch, CURLOPT_VERBOSE, false);
315+
if (\is_resource($ch)) {
316+
curl_setopt($ch, CURLOPT_VERBOSE, false);
317+
}
313318
}
314319
}
315320

0 commit comments

Comments
 (0)