Fix bugs for result of static analizer. 59/13259/2
authorKIM JungYong <jyong2.kim@samsung.com>
Thu, 13 Oct 2016 02:44:38 +0000 (11:44 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 14 Oct 2016 05:30:36 +0000 (05:30 +0000)
1. Initializatioin of local variable is added.
2. Invalid memory double free is removed on error handling.

Change-Id: I2d4c8460dd1e81ef88f6119f79deeae09c7f01c8
Signed-off-by: KIM JungYong <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13201
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit bae888047c3313e742f2b56cbab3366b118762e4)
Reviewed-on: https://gerrit.iotivity.org/gerrit/13259

service/notification/src/consumer/NSConsumerCommunication.c
service/notification/src/consumer/NSThread.c

index 8340d3b..4d4b62a 100644 (file)
@@ -335,6 +335,7 @@ OCRepPayload * NSGetExtraInfo(OCRepPayload * payload)
 {
     NS_LOG(DEBUG, "get extra info");
     OCRepPayload * extraInfo = OCRepPayloadCreate();
+    NS_VERIFY_NOT_NULL(extraInfo, NULL);
     OCRepPayload * origin = OCRepPayloadClone(payload);
 
     bool isFirstExtra = true;
@@ -628,7 +629,6 @@ void NSConsumerCommunicationTaskProcessing(NSTask * task)
         NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(connections,
         {
             NSRemoveProvider_internal((void *) provider);
-            NSRemoveProvider_internal((void *) task->taskData);
             NSOICFree(task);
         });
 
@@ -636,7 +636,6 @@ void NSConsumerCommunicationTaskProcessing(NSTask * task)
         NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(topicUri,
         {
             NSRemoveProvider_internal((void *) provider);
-            NSRemoveProvider_internal((void *) task->taskData);
             NSOICFree(task);
         });
 
@@ -655,7 +654,6 @@ void NSConsumerCommunicationTaskProcessing(NSTask * task)
         NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(query,
         {
             NSRemoveProvider_internal((void *) provider);
-            NSRemoveProvider_internal((void *) task->taskData);
             NSOICFree(task);
         });
         NS_LOG_V(DEBUG, "topic query : %s", query);
@@ -666,7 +664,6 @@ void NSConsumerCommunicationTaskProcessing(NSTask * task)
         NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(NSOCResultToSuccess(ret) == true ? (void *) 1 : NULL,
         {
             NSRemoveProvider_internal((void *) provider);
-            NSRemoveProvider_internal((void *) task->taskData);
             NSOICFree(task);
         });
 
index 5610636..36655d8 100644 (file)
@@ -53,7 +53,7 @@ NSConsumerThread * NSThreadInit(NSThreadFunc func, void * data)
 
     handle->isStarted = true;
 
-    pthread_attr_t attrDetached;
+    pthread_attr_t attrDetached = {};
     pthread_attr_init(& attrDetached);
     pthread_attr_setdetachstate(& attrDetached, PTHREAD_CREATE_DETACHED);