From d2c5ffda52a67c548f20fc8003d9aeb2aaf12867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 8 Nov 2019 00:12:08 +0100 Subject: [PATCH] [HttpClient] Fix a crash when calling CurlHttpClient::__destruct() --- .../Component/HttpClient/CurlHttpClient.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index e52a2cd0a5..632822b1ed 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -301,15 +301,20 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface public function __destruct() { $this->multi->pushedResponses = []; - if (\defined('CURLMOPT_PUSHFUNCTION')) { - curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null); + + if (\is_resource($this->multi->handle)) { + if (\defined('CURLMOPT_PUSHFUNCTION')) { + curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null); + } + + $active = 0; + while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active)); } - $active = 0; - while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active)); - foreach ($this->multi->openHandles as [$ch]) { - curl_setopt($ch, CURLOPT_VERBOSE, false); + if (\is_resource($ch)) { + curl_setopt($ch, CURLOPT_VERBOSE, false); + } } }