Skip to content

Commit

Permalink
Merge pull request #968 from libcpr/fix/curl_multi_reuse_after_free
Browse files Browse the repository at this point in the history
Fixed curl multi reuse after free
  • Loading branch information
COM8 authored Oct 14, 2023
2 parents e341350 + 81a5f2d commit fd9fa64
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cpr/multiperform.cpp
Original file line number Diff line number Diff line change
@@ -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 <algorithm>
Expand All @@ -16,6 +17,13 @@ MultiPerform::~MultiPerform() {
// Unlock all sessions
for (const std::pair<std::shared_ptr<Session>, 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<int>(error_code) << std::endl;
return;
}
}
}

Expand Down

0 comments on commit fd9fa64

Please sign in to comment.