Commit 11a2f8ab authored by Chetan Toshniwal's avatar Chetan Toshniwal Committed by Erich Keane

Fix memory leak in caqueueingthread

free preallocated memory on failure and return CA_MEMORY_ALLOC_FAILED. 

Change-Id: I9f5b9591b96d9dd0bf96bbaf7e9c5a6407ad831e
Signed-off-by: default avatarChetan Toshniwal <c.toshniwal@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1671Reviewed-by: default avatarErich Keane <erich.keane@intel.com>
Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
parent 35b6ae89
......@@ -146,8 +146,28 @@ CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, ca_thread_pool
thread->isStop = true;
thread->threadTask = task;
thread->destroy = destroy;
if(NULL == thread->dataQueue || NULL == thread->threadMutex || NULL == thread->threadCond)
goto ERROR_MEM_FAILURE;
return CA_STATUS_OK;
ERROR_MEM_FAILURE:
if(thread->dataQueue)
{
u_queue_delete(thread->dataQueue);
thread->dataQueue = NULL;
}
if(thread->threadMutex)
{
ca_mutex_free(thread->threadMutex);
thread->threadMutex = NULL;
}
if(thread->threadCond)
{
ca_cond_free(thread->threadCond);
thread->threadCond = NULL;
}
return CA_MEMORY_ALLOC_FAILED;
}
CAResult_t CAQueueingThreadStart(CAQueueingThread_t *thread)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment