From b97fe420192994b46c5bf35bdae005ffc185de73 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Wed, 25 Jan 2017 17:36:22 +0900 Subject: [PATCH] Fix memory leak - If body is floating, memory corruption is occured when msg get body in g_dbus_connection_send_message_with_reply() So, this problem can be solved by increase reference count of body when body is floating. Signed-off-by: seungha.son Change-Id: I166e0a2fb9e334c40fa9cfc37a998e5887492c4a --- lib/src/shortcut_internal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/shortcut_internal.c b/lib/src/shortcut_internal.c index d8f4238..2194ab9 100755 --- a/lib/src/shortcut_internal.c +++ b/lib/src/shortcut_internal.c @@ -378,6 +378,9 @@ int _send_async_shortcut(GVariant *body, struct result_cb_item *cb_item, char *c /* LCOV_EXCL_STOP */ } + if (g_variant_is_floating(body)) + g_variant_ref(body); + if (body != NULL) g_dbus_message_set_body(msg, body); @@ -391,6 +394,9 @@ int _send_async_shortcut(GVariant *body, struct result_cb_item *cb_item, char *c (GAsyncReadyCallback)_send_message_with_reply_sync_cb, cb_item); + if (msg) + g_object_unref(msg); + SHORTCUT_DBG("_send_async_shortcut done !!"); return SHORTCUT_ERROR_NONE; } -- 2.7.4