Fix BLE crash issue when IoTivity Stop is called. 75/17075/4
authorjihwan.seo <jihwan.seo@samsung.com>
Mon, 6 Feb 2017 10:35:56 +0000 (19:35 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Wed, 15 Feb 2017 00:11:02 +0000 (00:11 +0000)
Change-Id: Iee01565d5aab088c597f43f7bad463ab11553e41
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17075
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/calestate.c

index c1631a7..56cc314 100644 (file)
@@ -556,6 +556,11 @@ void CALEClientTerminate()
         OIC_LOG(ERROR, TAG, "CALERemoveAllDeviceState has failed");
     }
 
+    oc_mutex_lock(g_deviceStateListMutex);
+    OICFree(g_deviceStateList);
+    g_deviceStateList = NULL;
+    oc_mutex_unlock(g_deviceStateListMutex);
+
     ret = CALEClientRemoveAllScanDevices(env);
     if (CA_STATUS_OK != ret)
     {
@@ -3843,6 +3848,12 @@ void CALEClientTerminateGattMutexVariables()
 
     oc_mutex_free(g_threadScanIntervalMutex);
     g_threadScanIntervalMutex = NULL;
+
+    oc_mutex_free(g_gattObjectMutex);
+    g_gattObjectMutex = NULL;
+
+    oc_mutex_free(g_deviceStateListMutex);
+    g_deviceStateListMutex = NULL;
 }
 
 void CALEClientSetSendFinishFlag(bool flag)
index c407b1c..d9f7d96 100644 (file)
@@ -165,8 +165,6 @@ CAResult_t CALERemoveAllDeviceState(u_arraylist_t *deviceList,
         OICFree(state);
     }
 
-    OICFree(deviceList);
-    deviceList = NULL;
     oc_mutex_unlock(deviceListMutex);
 
     return CA_STATUS_OK;