common: Fix memory leak 70/134270/1
authorSyam Sidhardhan <s.syam@samsung.com>
Thu, 15 Jun 2017 14:22:34 +0000 (19:52 +0530)
committerSyam Sidhardhan <s.syam@samsung.com>
Thu, 15 Jun 2017 14:22:59 +0000 (19:52 +0530)
We have to free the allocated memory.

Change-Id: I040d3e0d57fa7967a5e4e3f456ec936b9f1f2ba2
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
src/bluetooth-common.c

index 081b1c1..2ea0c38 100644 (file)
@@ -1570,11 +1570,12 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                void *user_data = data->user_data;
                free(data);
 
-               bt_map_client_message_s* res = malloc(sizeof(*res));
+               bt_map_client_message_s *res = g_malloc0(sizeof(bt_map_client_message_s));
                res->file_path = target_file;
 
                ((bt_map_client_get_message_cb)bt_event_slot_container[event_index].callback)(
                        param->result, res, user_data);
+               g_free(res);
                break;
 
        case BLUETOOTH_EVENT_MAP_PUSH_MESSAGE_COMPLETE:
@@ -2467,6 +2468,8 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                         (_bt_get_error_code(param->result), (bt_device_att_mtu_info_s *)mtu_info,
                         bt_event_slot_container[event_index].user_data);
 
+               g_free(mtu_info);
+
                break;
        }
        case BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED: