Fix memory leak 66/71266/1
authorTaejin Woo <tt.woo@samsung.com>
Wed, 25 May 2016 00:47:47 +0000 (09:47 +0900)
committerTaejin Woo <tt.woo@samsung.com>
Wed, 25 May 2016 00:47:47 +0000 (09:47 +0900)
Change-Id: Ia7a5dbcd25e4825314ae3e7e577db3c557defc99
Signed-off-by: Taejin Woo <tt.woo@samsung.com>
bt-api/bt-gatt-client.c
bt-api/bt-gatt-service.c
bt-api/bt-hdp.c
bt-service/bt-service-adapter.c
bt-service/bt-service-gap-agent.c

index f3032da..2707994 100755 (executable)
@@ -564,6 +564,8 @@ BT_EXPORT_API int bluetooth_gatt_get_characteristics_property(
                                BT_DBG("value of char = %d",char_value);
                                g_byte_array_append(gb_array, &char_value, 1);
                        }
+                       g_variant_iter_free(char_value_iter);
+
                        if (gb_array->len != 0) {
                                characteristic->val = g_malloc0(gb_array->len *
                                                                sizeof(unsigned char));
@@ -586,6 +588,7 @@ BT_EXPORT_API int bluetooth_gatt_get_characteristics_property(
                        while (g_variant_iter_loop(char_desc_iter, "&o", &char_desc_handle)) {
                                g_ptr_array_add(gp_array, (gpointer)char_desc_handle);
                        }
+                       g_variant_iter_free(char_desc_iter);
                        if (gp_array->len != 0) {
                                characteristic->char_desc_handle.count = gp_array->len;
                                characteristic->char_desc_handle.handle =
@@ -775,6 +778,7 @@ BT_EXPORT_API int bluetooth_gatt_get_char_descriptor_property(
                                BT_DBG("value of descriptor = %d",char_value);
                                g_byte_array_append(gb_array, &char_value, 1);
                        }
+                       g_variant_iter_free(desc_value_iter);
                        if (gb_array->len != 0) {
                                descriptor->val = g_malloc0(gb_array->len *
                                                                sizeof(unsigned char));
@@ -1139,6 +1143,7 @@ static int __bluetooth_gatt_descriptor_iter(const char *char_handle,
                                                        &characteristic->description[i]);
                                                BT_DBG("description = %s", characteristic->description);
                                        }
+                                       g_variant_iter_free(desc_value_iter);
                                        break;
                                case CLIENT_CONF :
                                        BT_DBG(" CLIENT_CONF");
index ae02c02..0963319 100644 (file)
@@ -1325,6 +1325,8 @@ void get_service_cb(GObject *object, GAsyncResult *res, gpointer user_data)
                                BT_DBG("Descriptor %s", descriptor);
                        }
                }
+               g_variant_iter_free(iter);
+
                /* TODO: Store the service informationa and
                 * Send respponse to CAPI layer. */
 
index fe4589d..da56684 100755 (executable)
@@ -406,6 +406,8 @@ static void __bt_hdp_internal_handle_property_changed(GVariant *parameters)
                        break;
                }
        }
+       g_variant_iter_free(property_iter);
+
        g_free(property);
        g_variant_unref(value);
        g_free(obj_main_channel_path);
@@ -532,6 +534,7 @@ static int __bt_hdp_internal_acquire_fd(const char *path)
                        app_handle = g_variant_dup_string (value, &len);
                }
        }
+       g_variant_iter_free(property_iter);
 
        g_variant_unref(reply);
        BT_DBG("QOS = %s, Device = %s, Apphandler = %s",
index 13ed14a..184c746 100644 (file)
@@ -373,6 +373,8 @@ static int __bt_get_bonded_device_info(gchar *device_path,
                        while(g_variant_iter_loop(char_value_iter, "y",  &char_value)) {
                                g_byte_array_append(manufacturer_data, &char_value, 1);
                        }
+                       g_variant_iter_free(char_value_iter);
+
                        if (manufacturer_data) {
                                if (manufacturer_data->len > 0) {
                                        memcpy(dev_info->manufacturer_data.data, manufacturer_data->data,
@@ -381,6 +383,7 @@ static int __bt_get_bonded_device_info(gchar *device_path,
                        }
                }
        }
+       g_variant_iter_free(property_iter);
 
        BT_DBG("trust: %d, paired: %d", trust, paired);
 
index bf81920..f3e4964 100755 (executable)
@@ -1052,6 +1052,7 @@ void _gap_agent_setup_dbus(GapAgentPrivate *agent, GAP_AGENT_FUNC_CB *func_cb,
                        ERR("Unable to connect to gdbus: %s", error->message);
                        g_clear_error(&error);
                }
+               g_dbus_node_info_unref(node_info);
                return;
        }