diff --git a/src/core/download_list.cc b/src/core/download_list.cc index b67f590a..47b57084 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -726,11 +726,10 @@ DownloadList::process_meta_download(Download* download) { return; } - torrent::Object* bencode = new torrent::Object(torrent::Object::create_map()); + auto bencode = std::make_unique(torrent::Object::create_map()); file >> bencode->insert_key("info", torrent::Object()); if (file.fail()) { - delete bencode; lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download, the input is not a valid torrent."); return; } @@ -746,7 +745,7 @@ DownloadList::process_meta_download(Download* download) { erase_ptr(download); - control->core()->try_create_download_from_meta_download(bencode, metafile); + control->core()->try_create_download_from_meta_download(std::move(bencode), metafile); } } diff --git a/src/core/manager.cc b/src/core/manager.cc index 2e4d5f67..d88320a1 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -219,7 +219,7 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li } void -Manager::try_create_download_from_meta_download(torrent::Object* bencode, const std::string& metafile) { +Manager::try_create_download_from_meta_download(std::unique_ptr bencode, const std::string& metafile) { DownloadFactory* f = new DownloadFactory(this); f->variables()["tied_to_file"] = (int64_t)true; diff --git a/src/core/manager.h b/src/core/manager.h index 1965f3f2..942c4088 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -76,7 +76,7 @@ public: // Temporary, find a better place for this. void try_create_download(const std::string& uri, int flags, const command_list_type& commands); void try_create_download_expand(const std::string& uri, int flags, command_list_type commands = command_list_type()); - void try_create_download_from_meta_download(torrent::Object* bencode, const std::string& metafile); + void try_create_download_from_meta_download(std::unique_ptr bencode, const std::string& metafile); private: void create_http(const std::string& uri);