Svace memory leak fixes 13/214013/1
authorVitalii Irkha <v.irkha@samsung.com>
Tue, 10 Sep 2019 16:05:52 +0000 (19:05 +0300)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 17 Sep 2019 07:22:39 +0000 (16:22 +0900)
Fix memory leaks

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/12fafe1b6a94b3a7032bae5745143c246f79129f
(cherry-picked from 12fafe1b6a94b3a7032bae5745143c246f79129f)

Change-Id: I2015af65b4c865377db746e232842b4d52df1545
Signed-off-by: Vitalii Irkha <v.irkha@samsung.com>
Signed-off-by: Sudipto <sudipto.bal@samsung.com>
resource/csdk/security/provisioning/src/cloud/aclinvite.c
resource/csdk/security/provisioning/src/cloud/csr.c
resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c
resource/csdk/security/src/directpairing.c

index 31eb586..2a04675 100644 (file)
@@ -223,6 +223,13 @@ OCStackResult OCCloudAclInviteUser(void* ctx,
     }
 
     OCRepPayload **heplerPayload = OICCalloc(groupIds->length, sizeof(OCRepPayload *));
+    if(NULL == heplerPayload)
+    {
+        OICFree(cbData.context);
+        OCRepPayloadDestroy(payload);
+        OIC_LOG(ERROR, TAG, "Memory Allocation failed!");
+        return OC_STACK_NO_MEMORY;
+    }
 
     for (i = 0; i < groupIds->length; i++)
     {
index 3cb44fc..1fc2100 100644 (file)
@@ -289,6 +289,7 @@ static int GenerateCSR(char *subject, OCByteString *csr)
     {
         OIC_LOG(ERROR, TAG, "OICMalloc returned NULL on csr allocation");
         OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
+        OICFree(buf);
         return -1;
     }
     memcpy(csr->bytes, buf + bufsize - ret, ret * sizeof(uint8_t));
index 07b492e..71f95d7 100644 (file)
@@ -750,6 +750,7 @@ static OCStackResult SaveSubOwnerPSK(OCProvisionDev_t *selectedDeviceInfo)
         if (NULL == cred->privateData.data)
         {
             OICFree(b64Buf);
+            DeleteCredList(cred);
             return res;
         }
 
index 387df18..ed5aa60 100644 (file)
@@ -260,6 +260,7 @@ bool DPGenerateQuery(bool isSecure,
 #ifndef WITH_ARDUINO
         case CT_ADAPTER_TCP:
             prefix = (isSecure == true) ? QPREFIX_COAPS_TCP : QPREFIX_COAP_TCP;
+            /*FALLTHROUGH*/
 #endif
 #endif
         case CT_ADAPTER_IP: