From 5ebb7bd1517cf26f76878d95492314a335874229 Mon Sep 17 00:00:00 2001 From: noctuum <25441068+noctuum@users.noreply.github.com> Date: Wed, 16 Sep 2026 16:58:48 +0500 Subject: [PATCH] Call the target deleter in the tinyxml2 backend A tracker target allocates, and the deleter went out of scope unused. --- src/rpc/xmlrpc_tinyxml2.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/rpc/xmlrpc_tinyxml2.cc b/src/rpc/xmlrpc_tinyxml2.cc index 099f6fbd..a7f28cf1 100644 --- a/src/rpc/xmlrpc_tinyxml2.cc +++ b/src/rpc/xmlrpc_tinyxml2.cc @@ -19,6 +19,7 @@ #include "rpc/tinyxml2/tinyxml2.h" #include "rpc/rpc_manager.h" #include "utils/base64.h" +#include "utils/functional.h" #include "xmlrpc.h" namespace rpc { @@ -258,6 +259,8 @@ execute_command(std::string method_name, const tinyxml2::XMLElement* params_elem torrent::Object params_raw = torrent::Object::create_list(); torrent::Object::list_type& params = params_raw.as_list(); rpc::target_type target = rpc::make_target(); + std::function deleter = []() {}; + utils::scope_guard guard([&deleter]() { deleter(); }); if (params_element != nullptr) { if (std::strncmp(params_element->Name(), "params", sizeof("params")) == 0) { @@ -265,8 +268,6 @@ execute_command(std::string method_name, const tinyxml2::XMLElement* params_elem const auto* child = params_element->FirstChildElement("param"); if (child != nullptr) { - std::function deleter = []() {}; - RpcManager::object_to_target(xml_value_to_object(child->FirstChildElement("value")), cmd_itr->second.m_flags, &target, &deleter); child = child->NextSiblingElement("param"); @@ -282,8 +283,6 @@ execute_command(std::string method_name, const tinyxml2::XMLElement* params_elem const auto* child = params_element->FirstChildElement("data")->FirstChildElement("value"); if (child != nullptr) { - std::function deleter = []() {}; - RpcManager::object_to_target(xml_value_to_object(child), cmd_itr->second.m_flags, &target, &deleter); child = child->NextSiblingElement("value");