Fix the crash issue in OTP manual testcase 03/155103/1 accepted/tizen/4.0/unified/20171017.211455 submit/tizen_4.0/20171016.011411
authorDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 12 Oct 2017 05:45:14 +0000 (14:45 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 12 Oct 2017 05:45:14 +0000 (14:45 +0900)
Change-Id: I767113f01ede106b6a99b8ab85a97acc3f9721bb
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
src/bluetooth-otp.c

index 2dcf1b95363af39547f535c90f54810953732f6d..688f94e217c7be975a32d57fa3b44c82f42cb6e9 100644 (file)
@@ -2044,12 +2044,18 @@ void _bt_otc_connection_state_changed(int result, bluetooth_otc_info_t *otc_info
                if (otp_client_s->curr_op == BT_OTP_OBJECT_WRITE) {
                        _bt_otp_client_write_on_fd(otc_info);
                } else if (otp_client_s->curr_op == BT_OTP_OBJECT_READ) {
+                       bluetooth_otc_info_t *new_otc_info = g_malloc0(sizeof(bluetooth_otc_info_t));
+
+                       new_otc_info->fd = otc_info->fd;
+                       new_otc_info->connected = otc_info->connected;
+                       new_otc_info->address = g_strdup(otc_info->address);
+
                        id = g_io_add_watch(data_io,
                                G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-                               __client_data_received_cb, (gpointer)otc_info);
+                               __client_data_received_cb, (gpointer)new_otc_info);
 
                        timeout_id = g_timeout_add(BT_OTC_CONNECTION_MAX_TIMEOUT,
-                               (GSourceFunc)__bt_otc_connection_timeout_cb, (gpointer)otc_info);
+                               (GSourceFunc)__bt_otc_connection_timeout_cb, (gpointer)new_otc_info);
                }
        } else {
                BT_DBG("OTC Disconnected");