Skip to content

Commit

Permalink
Fixed curl multi reuse after free
Browse files Browse the repository at this point in the history
  • Loading branch information
COM8 committed Oct 13, 2023
1 parent e341350 commit 81a5f2d
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 81a5f2d

Please sign in to comment.