[HAL]Fix Resource leak (CoverityID:859600, 859593) 40/183740/1
authorAtul Rai <a.rai@samsung.com>
Tue, 10 Jul 2018 06:38:16 +0000 (12:08 +0530)
committerAtul Rai <a.rai@samsung.com>
Tue, 10 Jul 2018 06:38:16 +0000 (12:08 +0530)
Change-Id: If8b2ae56bc402e7e5bcf2eb4f656c7ee9681d744
Signed-off-by: Atul Rai <a.rai@samsung.com>
bt-oal/bluez_hal/src/bt-hal-gatt-client.c
bt-oal/bluez_hal/src/bt-hal-gatt-server.c

index 568d737..148b339 100644 (file)
@@ -1195,13 +1195,13 @@ static bt_status_t _hal_gattc_get_descriptor_info(hal_gattc_desc_t *gattc_desc)
 
        while (g_variant_iter_loop(property_iter, "{sv}", &key, &value)) {
                if (!g_strcmp0(key, "UUID")) {
-                       desc_uuid_str = g_variant_dup_string(value, &len);
+                       desc_uuid_str = g_variant_get_string(value, &len);
                        DBG("desc UUID [%s]", desc_uuid_str);
+                       _hal_gattc_update_desc_property(gattc_desc, desc_uuid_str);
+                       break;
                }
        }
 
-       _hal_gattc_update_desc_property(gattc_desc, desc_uuid_str);
-
        g_variant_iter_free(property_iter);
        g_variant_unref(result);
        g_object_unref(properties_proxy);
index 649639e..12f672a 100644 (file)
@@ -1728,6 +1728,7 @@ static char* __bt_hal_convert_uuid_to_string(bt_uuid_t *srvc_id)
 
 int __bt_hal_add_service_to_dbus(char *app_path, int slot, btgatt_srvc_id_t *srvc_id)
 {
+       gboolean ret;
        /* For GATT service specific */
        GDBusNodeInfo *node_info;
        guint object_id;
@@ -1796,12 +1797,20 @@ int __bt_hal_add_service_to_dbus(char *app_path, int slot, btgatt_srvc_id_t *srv
        g_variant_builder_add(builder, "{sa{sv}}",
                        GATT_SERV_INTERFACE, inner_builder);
 
-       g_dbus_connection_emit_signal(g_conn, NULL, "/",
+       ret = g_dbus_connection_emit_signal(g_conn, NULL, "/",
                        "org.freedesktop.Dbus.ObjectManager",
                        "InterfacesAdded",
                        g_variant_new("(oa{sa{sv}})",
                                path, builder),
                        &error);
+       if (!ret) {
+               if (error) {
+                       /* dbus gives error cause */
+                       ERR("d-bus api failure: errcode[%x], message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
+       }
 
        /* Send Service handle to application */
        user_data = g_malloc0(sizeof(hal_gatt_service_added));
@@ -2080,6 +2089,7 @@ static bt_status_t gatt_server_add_characteristic(int slot, int service_handle,
                bt_uuid_t *uuid, int properties,
                int permissions)
 {
+       gboolean ret;
        GError *error = NULL;
        guint object_id;
        GDBusNodeInfo *node_info;
@@ -2181,12 +2191,20 @@ static bt_status_t gatt_server_add_characteristic(int slot, int service_handle,
                        GATT_CHAR_INTERFACE,
                        inner_builder);
 
-       g_dbus_connection_emit_signal(g_conn, NULL, "/",
+       ret = g_dbus_connection_emit_signal(g_conn, NULL, "/",
                        "org.freedesktop.Dbus.ObjectManager",
                        "InterfacesAdded",
                        g_variant_new("(oa{sa{sv}})",
                                path, builder),
                        &error);
+       if (!ret) {
+               if (error) {
+                       /* dbus gives error cause */
+                       ERR("d-bus api failure: errcode[%x], message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
+       }
 
        //*char_path = g_strdup(path);