Fix static analysis tool warnings
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-event-handler.c
index 8f6cc2b..c0f8016 100644 (file)
@@ -2045,7 +2045,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                g_variant_get(folder_list_var, "(aa{sv})", &iter);
 
                folders_struct.size = g_variant_iter_n_children(iter);
-               folders_struct.names = (char**) malloc(folders_struct.size * sizeof(*(folders_struct.names)));
+               folders_struct.names = (char**) g_malloc0(folders_struct.size * sizeof(*(folders_struct.names)));
                BT_DBG("g_variant_iter_n_children: %d", folders_struct.size);
                GVariantIter* res = NULL;
                int i = 0;
@@ -2071,7 +2071,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                        free(folders_struct.names[i]);
                        folders_struct.names[i] = NULL;
                }
-               free(folders_struct.names);
+               g_free(folders_struct.names);
 
                g_variant_unref(folder_list_var);
 
@@ -2096,7 +2096,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                        fields_info.size  = g_variant_iter_n_children(iter);
                        char* field = NULL;
 
-                       fields_info.fields = malloc(fields_info.size * sizeof(char*));
+                       fields_info.fields = g_malloc0(fields_info.size * sizeof(char*));
                        while (g_variant_iter_loop(iter, "s", &field)) {
                                fields_info.fields[i] = strdup(field);
                                i++;
@@ -2111,7 +2111,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                        free(fields_info.fields[i]);
                        fields_info.fields[i] = NULL;
                }
-               free(fields_info.fields);
+               g_free(fields_info.fields);
 
                __bt_remove_push_request_id(request_id);
                g_variant_unref(value);
@@ -2130,7 +2130,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                g_variant_get(messages_list_var, "(a{oa{sv}})", &iter);
                messages_struct.size = g_variant_iter_n_children(iter);
                messages_struct.message_items = (bt_map_client_message_item_t*)
-                       malloc(messages_struct.size * sizeof(*(messages_struct.message_items)));
+                       g_malloc(messages_struct.size * sizeof(*(messages_struct.message_items)));
                BT_DBG("g_variant_iter_n_children: %d", messages_struct.size);
 
                char *object = NULL;
@@ -2253,7 +2253,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                        free(messages_struct.message_items[i].type);
                        free(messages_struct.message_items[i].status);
                }
-               free(messages_struct.message_items);
+               g_free(messages_struct.message_items);
 
                g_variant_unref(messages_list_var);
        } else if (strcasecmp(signal_name, BT_MAP_GET_MESSAGE_COMPLETE) == 0) {