Fixed klockwork memory leaks and modified the logs
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / caqueueingthread.c
index 7fcbba3..fc6b2d1 100644 (file)
@@ -99,16 +99,18 @@ static void CAQueueingThreadBaseRoutine(void *threadValue)
         u_queue_message_t *message = u_queue_get_element(thread->dataQueue);
 
         // free
-        if (thread->destroy != NULL)
-        {
-            thread->destroy(message->msg, message->size);
+        if(message != NULL) {
+            if (thread->destroy != NULL)
+            {
+                thread->destroy(message->msg, message->size);
+            }
+            else
+            {
+                OICFree(message->msg);
+            }
+
+            OICFree(message);
         }
-        else
-        {
-            OICFree(message->msg);
-        }
-
-        OICFree(message);
     }
 
     u_cond_signal(thread->threadCond);