--- src/core/download_list.cc.old	2009-10-21 02:30:42.000000000 -0700
+++ src/core/download_list.cc	2009-10-21 03:34:11.000000000 -0700
@@ -563,13 +563,18 @@
   // up/downloaded baseline.
   download->download()->tracker_list()->send_completed();
 
+	// save the hash in case the event deletes the object (e.g. d.erase)
+	torrent::HashString infohash = download->download()->info_hash();
+
   rpc::commands.call_catch("event.download.finished", rpc::make_target(download), torrent::Object(), "Download event action failed: ");
 
   if (download->resume_flags() != ~uint32_t())
     throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != ~uint32_t().");
 
-	if (!download->is_active() && rpc::call_command_value("d.get_state", rpc::make_target(download)) == 1)
-		resume(download, torrent::Download::start_no_create | torrent::Download::start_skip_tracker | torrent::Download::start_keep_baseline);
+  if (find(infohash) != end()) {
+		if (!download->is_active() && rpc::call_command_value("d.get_state", rpc::make_target(download)) == 1)
+			resume(download, torrent::Download::start_no_create | torrent::Download::start_skip_tracker | torrent::Download::start_keep_baseline);
+	}
 }
 
 }

