Fix memory leak in bt-api for g_variant_iter_loop 93/224293/2
authorAmit Purwar <amit.purwar@samsung.com>
Fri, 7 Feb 2020 11:51:36 +0000 (17:21 +0530)
committerPyun DoHyun <dh79.pyun@samsung.com>
Tue, 11 Feb 2020 00:32:50 +0000 (00:32 +0000)
Change-Id: I4ac3e7f1f862b47d7c4737e69d856000315e32b4
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
bt-api/bt-audio.c
bt-api/bt-event-handler.c
bt-api/bt-gatt-client.c

index 1b12414..46c29fc 100644 (file)
@@ -565,6 +565,8 @@ static int __bt_hf_agent_read_call_list(GVariant *reply,
                (*call_list)->list = g_list_append((*call_list)->list,
                                                        (gpointer)call_info);
        }
+
+       g_variant_unref(var_temp);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
index 91108b4..ea3d35e 100644 (file)
@@ -2247,6 +2247,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                }
                g_free(folders_struct.names);
 
+               g_variant_iter_free(iter);
                g_variant_unref(folder_list_var);
 
        } else if (strcasecmp(signal_name, BT_MAP_FILTER_FIELDS_COMPLETE) == 0) {
@@ -2275,6 +2276,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                                fields_info.fields[i] = strdup(field);
                                i++;
                        }
+                       g_variant_iter_free(iter);
                }
 
                _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE,
@@ -2405,9 +2407,12 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                                        messages_struct.message_items[i].is_protected = value_bool ? 1 : 0;
                                        BT_DBG("  Protected: %s", value_bool ? "true" : "false");
                                }
+
+                               g_free(value_string);
                        }
                        ++i;
                }
+               g_variant_iter_free(iter);
 
                _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_MESSAGES_COMPLETE,
                                result, &messages_struct,
index ca6709d..887870f 100644 (file)
@@ -439,6 +439,13 @@ BT_EXPORT_API int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_
                                                g_strstr_len(service->uuid, -1,
                                                                service_uuid)) {
                                        ret = BLUETOOTH_ERROR_NONE;
+
+                                       /* release resources */
+                                       g_free(object_path);
+                                       g_variant_iter_free(interface_iter);
+                                       g_free(interface_str);
+                                       g_variant_iter_free(svc_iter);
+
                                        goto done;
                                }
                        }
@@ -515,6 +522,7 @@ static void __bluetooth_internal_get_char_cb(GDBusProxy *proxy,
        g_variant_iter_free(char_iter);
        g_variant_unref(value);
        g_object_unref(proxy);
+       g_variant_unref(char_value);
 }
 
 BT_EXPORT_API int bluetooth_gatt_discover_service_characteristics(
@@ -1476,10 +1484,11 @@ static void bluetooth_gatt_get_char_desc_cb(GDBusProxy *proxy,
 
        g_variant_iter_free(char_iter);
        g_variant_unref(value);
+       g_variant_unref(char_value);
        BT_DBG("-");
 }
 
-BT_EXPORT_API int bluetooth_gatt_discover_characteristic_descriptor(
+BT_EXPORT_API int bltooth_gatt_discover_characteristic_descriptor(
                        const char *characteristic_handle)
 {
        GDBusProxy *properties_proxy = NULL;