fix: crash in curl_easy_pause() (#5161)

This commit is contained in:
Charles Kerr 2023-03-05 23:42:52 -06:00 committed by GitHub
parent 08ed1cf54c
commit b2b0f0db39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -351,6 +351,8 @@ public:
return;
}
impl.paused_easy_handles.erase(easy_);
if (auto const url = tr_urlParse(options.url); url)
{
curl_easy_reset(easy);
@ -462,7 +464,7 @@ public:
// again when the transfer is unpaused.
if (task->impl.mediator.clamp(*tag, bytes_used) < bytes_used)
{
task->impl.paused_easy_handles.emplace(tr_time_msec(), task->easy());
task->impl.paused_easy_handles.emplace(task->easy(), tr_time_msec());
return CURL_WRITEFUNC_PAUSE;
}
@ -601,9 +603,9 @@ public:
for (auto it = std::begin(paused); it != std::end(paused);)
{
if (it->first + BandwidthPauseMsec < now)
if (it->second + BandwidthPauseMsec < now)
{
curl_easy_pause(it->second, CURLPAUSE_CONT);
curl_easy_pause(it->first, CURLPAUSE_CONT);
it = paused.erase(it);
}
else
@ -777,7 +779,7 @@ public:
static inline auto curl_init_flag = std::once_flag{};
std::multimap<uint64_t /*tr_time_msec()*/, CURL*> paused_easy_handles;
std::map<CURL*, uint64_t /*tr_time_msec()*/> paused_easy_handles;
static void curlInit()
{