From b34eb1e895bd89a379f93b26817e647c53ba5805 Mon Sep 17 00:00:00 2001 From: noctuum <25441068+noctuum@users.noreply.github.com> Date: Fri, 18 Sep 2026 13:41:46 +0500 Subject: [PATCH] Own the download factory until commit A malformed data uri threw before commit, and nothing deleted it. --- src/core/manager.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/manager.cc b/src/core/manager.cc index d88320a1..1fcb55c1 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -195,14 +195,14 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li return; // Adding download. - DownloadFactory* f = new DownloadFactory(this); + auto f = std::make_unique(this); f->variables()["tied_to_file"] = (int64_t)(bool)(flags & create_tied); f->commands().insert(f->commands().end(), commands.begin(), commands.end()); f->set_start(flags & create_start); f->set_print_log(!(flags & create_quiet)); - f->slot_finished([f]() { delete f; }); + f->slot_finished([factory = f.get()]() { delete factory; }); if (is_data_uri(uri)) { // Allow the use of data URIs, primarily for JSON-RPC which @@ -216,6 +216,9 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li } f->commit(); + + // From here the finished slot deletes it. + f.release(); } void