Fix mem leak.
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-hid-device.c
index 93cd4fd..b287ca7 100644 (file)
@@ -238,19 +238,17 @@ static gboolean __hid_disconnect(hid_connected_device_info_t *info)
        }
        info->disconnect_idle_id = 0;
        event_info = _bt_event_get_cb_data(BT_HID_DEVICE_EVENT);
-       if (event_info == NULL)
-               return FALSE;
+       if (event_info != NULL) {
+               memset(&bd_addr, 0x00, sizeof(bluetooth_device_address_t));
+               _bt_convert_addr_string_to_type(bd_addr.addr , info->address);
+               _bt_common_event_cb(BLUETOOTH_HID_DEVICE_DISCONNECTED,
+                               BLUETOOTH_ERROR_NONE, &bd_addr,
+                               event_info->cb, event_info->user_data);
+       }
 
-       memset(&bd_addr, 0x00, sizeof(bluetooth_device_address_t));
-       _bt_convert_addr_string_to_type(bd_addr.addr , info->address);
-       _bt_common_event_cb(BLUETOOTH_HID_DEVICE_DISCONNECTED,
-                       BLUETOOTH_ERROR_NONE, &bd_addr,
-                       event_info->cb, event_info->user_data);
-       if (info->address)
-               g_free(info->address);
+       g_free(info->address);
        g_free(info);
-       info = NULL;
-       BT_DBG("-");
+
        return FALSE;
 }