Fix defect detected by static code analyzer
authorYunheeHwang <yunhee.hwang@samsung.com>
Wed, 29 Mar 2017 09:45:47 +0000 (18:45 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Fri, 31 Mar 2017 17:05:10 +0000 (17:05 +0000)
Problem : Dynamic memory referenced by (*set)->actionsetName was allocated by calling malloc and lost without free before exit
Resolve : add OCFREE((*set)->actionsetName) before OCFREE(*set)

Problem : Dynamic memory referenced by payload was allocated by calling function 'OCRepPayloadCreate' and lost without free before exit
Resolve : add OCRepPayloadDestroy(payload) to free them

Change-Id: I2f8bbbd009c567cda8c091ffde925f1692416c9b
Signed-off-by: YunheeHwang <yunhee.hwang@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18259
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/csdk/stack/src/oicgroup.c

index 881f838..3f0a6ac 100755 (executable)
@@ -736,6 +736,7 @@ exit:
     OCFREE(desc)
     OCFREE(capa)
     OCFREE(action)
+    OCFREE((*set)->actionsetName)
     OCFREE(*set)
     OCFREE(key)
     OCFREE(value)
@@ -1198,6 +1199,7 @@ OCStackResult BuildCollectionGroupActionCBORResponse(
                 stackRet = OC_STACK_ERROR;
             }
         }
+        OCRepPayloadDestroy(payload);
     }
     else if (method == OC_REST_POST)
     {
@@ -1376,6 +1378,7 @@ OCStackResult BuildCollectionGroupActionCBORResponse(
                 stackRet = OC_STACK_ERROR;
             }
         }
+        OCRepPayloadDestroy(payload);
     }
 
 exit: