Fix the crash 00/229700/1 accepted/tizen/unified/20200406.133118 submit/tizen/20200405.220144
authorinjun.yang <injun.yang@samsung.com>
Fri, 3 Apr 2020 02:34:10 +0000 (11:34 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 3 Apr 2020 02:45:53 +0000 (11:45 +0900)
[Model] All
[BinType] AP
[Customer] OPEN

[Issue#] N/A
[Request] Internal
[Occurrence Version] N/A

[Problem]
[Cause & Measure]
[Checking Method]

[Team] Convergence BT
[Developer] Injun Yang
[Solution company] Samsung
[Change Type] Specification change

Change-Id: I2801a6b168701151c7755be549977cac3439f410
Signed-off-by: injun.yang <injun.yang@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-service-adaptation/services/bt-service-battery-monitor.c

index 2069a54..2219b3a 100644 (file)
@@ -543,34 +543,36 @@ static void __bt_notify_battery_data(void)
 
        if (result != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Battery data not collected");
+               g_free(data);
+               return;
        }
-       else {
-               bt_battery_dbus_data_t dbus_data;
-               memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
-               dbus_data.session_start_time = data->session_start_time;
-               dbus_data.session_end_time = data->session_end_time;
-               dbus_data.session_scan_time = data->session_scan_time;
-               dbus_data.session_connected_time = data->session_connected_time;
-               dbus_data.tx_time = data->tx_time;
-               dbus_data.rx_time = data->rx_time;
-               dbus_data.idle_time = data->idle_time;
-
-               /*Populating app data*/
-               int n = 0;
-               for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
-                       bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
-                       memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
-                       n++;
-               }
-               dbus_data.num_app = n;
 
-               info = g_array_new(FALSE, FALSE, sizeof(gchar));
-               g_array_append_vals(info, &dbus_data, sizeof(bt_battery_dbus_data_t));
+       bt_battery_dbus_data_t dbus_data;
+       memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
+       dbus_data.session_start_time = data->session_start_time;
+       dbus_data.session_end_time = data->session_end_time;
+       dbus_data.session_scan_time = data->session_scan_time;
+       dbus_data.session_connected_time = data->session_connected_time;
+       dbus_data.tx_time = data->tx_time;
+       dbus_data.rx_time = data->rx_time;
+       dbus_data.idle_time = data->idle_time;
 
-               out_var = g_variant_new_from_data((const GVariantType *)"ay",
-                               info->data, info->len,
-                               TRUE, NULL, NULL);
+       /*Populating app data*/
+       int n = 0;
+       for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
+               bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
+               memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
+               n++;
        }
+       dbus_data.num_app = n;
+
+       info = g_array_new(FALSE, FALSE, sizeof(gchar));
+       g_array_append_vals(info, &dbus_data, sizeof(bt_battery_dbus_data_t));
+
+       out_var = g_variant_new_from_data((const GVariantType *)"ay",
+                       info->data, info->len,
+                       TRUE, NULL, NULL);
+
        param = g_variant_new("(iv)", result, out_var);
        _bt_send_event(BT_ADAPTER_EVENT,
                BLUETOOTH_EVENT_DISABLED_BATTERY_DATA,