Make sure we don't access freed memory if a download is erased during the erased event.

This commit is contained in:
Jari Sundell
2011-12-11 12:21:24 +09:00
parent 081b5e9cb2
commit 21944b941a
+4 -2
View File
@@ -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 |