Fix wrong variable access in SendDataAsync 20/312920/2
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 17 Jun 2024 08:38:37 +0000 (17:38 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 17 Jun 2024 08:46:49 +0000 (17:46 +0900)
The local variable std::pair is invalid with
the end of the SendDataAsync function

Change-Id: I7f7a2626418ff05c6f6c721fa2cb1f6e35b05630
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/theme/dbus/request_broker.cc

index 49ea7517347a8cc4e33dd94b6ed2607f98410c78..b712d40c4d0fa8332b8834cdd445052e6645e6f2 100644 (file)
@@ -285,13 +285,14 @@ void RequestBroker::SendDataAsync(Command cmd, tizen_base::Bundle& data) {
   g_dbus_message_set_body(msg, g_variant_new("(is)", static_cast<int>(cmd),
           reinterpret_cast<char*>(data.ToRaw().first.get())));
 
-  std::pair<Command, RequestBroker*> param = std::make_pair(cmd, this);
+  auto param = new std::pair<Command, RequestBroker*>(cmd, this);
 
   g_dbus_connection_send_message_with_reply(connection_, msg,
       G_DBUS_SEND_MESSAGE_FLAGS_NONE, kTimeoutMsec, nullptr, nullptr,
       [](GObject* source_object, GAsyncResult* res, gpointer user_data) {
         auto param =
             static_cast<std::pair<Command, RequestBroker*>*>(user_data);
+        std::unique_ptr<std::pair<Command, RequestBroker*>> param_auto(param);
         GDBusConnection* conn =
             reinterpret_cast<GDBusConnection*>(source_object);
         GError* err = nullptr;
@@ -319,7 +320,7 @@ void RequestBroker::SendDataAsync(Command cmd, tizen_base::Bundle& data) {
           return;
         it->second->GetHandler()->OnRequest(Command::RESULT, b);
       },
-      &param);
+      param);
 }
 
 }  // namespace dbus