Fix memory leak 03/112003/1 tizen_3.0_tv accepted/tizen/3.0/common/20170201.164551 accepted/tizen/3.0/ivi/20170201.091706 accepted/tizen/3.0/mobile/20170201.091522 accepted/tizen/3.0/tv/20170201.091604 accepted/tizen/3.0/wearable/20170201.091627 submit/tizen_3.0/20170201.003016
authorseungha.son <seungha.son@samsung.com>
Wed, 25 Jan 2017 08:36:22 +0000 (17:36 +0900)
committerseungha.son <seungha.son@samsung.com>
Wed, 25 Jan 2017 08:38:00 +0000 (17:38 +0900)
 - 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 <seungha.son@samsung.com>
Change-Id: I166e0a2fb9e334c40fa9cfc37a998e5887492c4a

lib/src/shortcut_internal.c

index d8f4238..2194ab9 100755 (executable)
@@ -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;
 }