From 21944b941a7a418f7bdc56ff5a5bc5965c2b65c9 Mon Sep 17 00:00:00 2001 From: Jari Sundell Date: Sun, 11 Dec 2011 12:21:24 +0900 Subject: [PATCH] Make sure we don't access freed memory if a download is erased during the erased event. --- src/core/download_list.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/download_list.cc b/src/core/download_list.cc index 939e6ff7..e255434f 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -642,6 +642,9 @@ DownloadList::confirm_finished(Download* download) { DL_TRIGGER_EVENT(download, "event.download.finished"); + if (find(infohash) != end()) + return; + // if (download->resume_flags() != ~uint32_t()) // throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != ~uint32_t()."); @@ -655,8 +658,7 @@ DownloadList::confirm_finished(Download* download) { // being hashed. download->set_resume_flags(~uint32_t()); - if (find(infohash) != end() && - !download->is_active() && rpc::call_command_value("d.state", rpc::make_target(download)) == 1) + if (!download->is_active() && rpc::call_command_value("d.state", rpc::make_target(download)) == 1) resume(download, torrent::Download::start_no_create | torrent::Download::start_skip_tracker |