Fix crash in ssl retransmission thread
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / adapter_util / ca_adapter_net_ssl.c
index b490c8a..d0f44bd 100644 (file)
@@ -1214,6 +1214,7 @@ static void StopRetransmit()
     if (g_caSslContext)
     {
         unregisterTimer(g_caSslContext->timerId);
+        g_caSslContext->timerId= -1;
     }
 }
 #endif
@@ -1292,12 +1293,14 @@ static int StartRetransmit()
     uint32_t listIndex = 0;
     uint32_t listLength = 0;
     SslEndPoint_t *tep = NULL;
+
+    ca_mutex_lock(g_sslContextMutex);
     if (NULL == g_caSslContext)
     {
         OIC_LOG(ERROR, NET_SSL_TAG, "Context is NULL. Stop retransmission");
+        ca_mutex_unlock(g_sslContextMutex);
         return -1;
     }
-    ca_mutex_lock(g_sslContextMutex);
     if (g_caSslContext->timerId != -1)
     {
         //clear previous timer