Fixed memory leak on CARetransmissionDestroy 07/17207/2
authorJaewook Jung <jw0213.jung@samsung.com>
Fri, 10 Feb 2017 07:26:51 +0000 (16:26 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Wed, 15 Feb 2017 06:04:29 +0000 (06:04 +0000)
Change-Id: Ic53ae0759020fa26f5f70425d3dab09ff5e7d375
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17207
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/caretransmission.c

index f9cb544..0f78f31 100644 (file)
@@ -638,6 +638,20 @@ CAResult_t CARetransmissionDestroy(CARetransmission_t *context)
 
     OIC_LOG(DEBUG, TAG, "retransmission context destroy..");
 
+    oc_mutex_lock(context->threadMutex);
+    uint32_t len = u_arraylist_length(context->dataList);
+    for (uint32_t i = 0; i < len; i++)
+    {
+        CARetransmissionData_t *data = u_arraylist_get(context->dataList, i);
+        if (NULL == data)
+        {
+            continue;
+        }
+        CAFreeEndpoint(data->endpoint);
+        OICFree(data->pdu);
+    }
+    oc_mutex_unlock(context->threadMutex);
+
     oc_mutex_free(context->threadMutex);
     context->threadMutex = NULL;
     oc_cond_free(context->threadCond);