From 81a5f2df9bae4a11ee98818181d54ab1d80aafbb Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 13 Oct 2023 19:22:56 +0200 Subject: [PATCH] Fixed curl multi reuse after free --- cpr/multiperform.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpr/multiperform.cpp b/cpr/multiperform.cpp index 051f2d687..f038d00e6 100644 --- a/cpr/multiperform.cpp +++ b/cpr/multiperform.cpp @@ -1,6 +1,7 @@ #include "cpr/multiperform.h" #include "cpr/interceptor.h" +#include "cpr/multipart.h" #include "cpr/response.h" #include "cpr/session.h" #include @@ -16,6 +17,13 @@ MultiPerform::~MultiPerform() { // Unlock all sessions for (const std::pair, HttpMethod>& pair : sessions_) { pair.first->isUsedInMultiPerform = false; + + // Remove easy handle from multi handle + const CURLMcode error_code = curl_multi_remove_handle(multicurl_->handle, pair.first->curl_->handle); + if (error_code) { + std::cerr << "curl_multi_remove_handle() failed, code " << static_cast(error_code) << std::endl; + return; + } } }