common: Fix memory leak 65/141965/1
authorSyam Sidhardhan <s.syam@samsung.com>
Wed, 31 May 2017 06:48:10 +0000 (12:18 +0530)
committerNagaraj D R <nagaraj.dr@samsung.com>
Wed, 2 Aug 2017 06:23:28 +0000 (11:53 +0530)
Memory leak reported by the cppcheck based sonarQube tool

Change-Id: I0384dab0f95124274abe0f8407b3097714e73312

src/bluetooth-common.c

index f58d8b5a89e16af9ffa963f09ea572b4d362ce05..ca4f90b4e691070115f3b868b4988544b1ad9775 100644 (file)
@@ -1632,11 +1632,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:
@@ -2456,6 +2457,8 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                __bt_get_bt_device_att_mtu_info_s(&mtu_info, (bluetooth_le_att_mtu_info_t *)(param->param_data));
                ((bt_device_att_mtu_changed_cb)bt_event_slot_container[event_index].callback)
                 (_bt_get_error_code(param->result), mtu_info, bt_event_slot_container[event_index].user_data);
+
+               g_free(mtu_info);
                break;
        }
        case BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED: