From 8036af63581033895c91a35fc9e42fc1e9c39626 Mon Sep 17 00:00:00 2001 From: jihwanseo Date: Fri, 10 Feb 2017 16:26:51 +0900 Subject: [PATCH] Fixed memory leak on OCSetDeviceInfo and CARetransmissionDestroy Change-Id: Ic53ae0759020fa26f5f70425d3dab09ff5e7d375 Signed-off-by: Jaewook Jung Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/17167 Tested-by: jenkins-iotivity Reviewed-by: Jaehong Jo Reviewed-by: jaehyun Cho Reviewed-by: Ashok Babu Channa --- resource/csdk/connectivity/src/caretransmission.c | 13 +++++++++++++ resource/csdk/stack/src/ocresource.c | 1 + 2 files changed, 14 insertions(+) diff --git a/resource/csdk/connectivity/src/caretransmission.c b/resource/csdk/connectivity/src/caretransmission.c index c8b2b08..65d32c7 100644 --- a/resource/csdk/connectivity/src/caretransmission.c +++ b/resource/csdk/connectivity/src/caretransmission.c @@ -632,6 +632,19 @@ CAResult_t CARetransmissionDestroy(CARetransmission_t *context) OIC_LOG(DEBUG, TAG, "retransmission context destroy.."); + ca_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); + } + ca_mutex_unlock(context->threadMutex); ca_mutex_free(context->threadMutex); context->threadMutex = NULL; ca_cond_free(context->threadCond); diff --git a/resource/csdk/stack/src/ocresource.c b/resource/csdk/stack/src/ocresource.c index a8747ba..70f6924 100755 --- a/resource/csdk/stack/src/ocresource.c +++ b/resource/csdk/stack/src/ocresource.c @@ -1436,6 +1436,7 @@ OCStackResult OCSetDeviceInfo(OCDeviceInfo info) { dataModelVersion = OCCreateOCStringLL(OC_DATA_MODEL_VERSION); VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION, dataModelVersion)); + OCFreeOCStringLL(dataModelVersion); } OIC_LOG(INFO, TAG, "Device parameter initialized successfully."); return OC_STACK_OK; -- 2.7.4