Memleak fix 90/213990/1
authorOleksii Beketov <ol.beketov@samsung.com>
Tue, 10 Sep 2019 12:11:00 +0000 (15:11 +0300)
committerSudipto <sudipto.bal@samsung.com>
Tue, 17 Sep 2019 06:20:18 +0000 (11:50 +0530)
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/9ea7c80e82baee3f896d31f31397e8d6b92afa25
(cherry-picked from 9ea7c80e82baee3f896d31f31397e8d6b92afa25)

Change-Id: Id194ae5ee25c1fb48c4a177836dec2a138d0869f
Signed-off-by: Sudipto <sudipto.bal@samsung.com>
resource/csdk/security/provisioning/src/secureresourceprovider.c

index b93fc0a..af5ecf9 100644 (file)
@@ -599,7 +599,12 @@ OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
     if (encodingType == OIC_ENCODING_PEM)
     {
         cred->optionalData.data = (uint8_t *)OICCalloc(1, chainSize + 1);
-        VERIFY_NON_NULL_RET(TAG, cred->optionalData.data, ERROR, OC_STACK_NO_MEMORY);
+        if (cred->optionalData.data == NULL)
+        {
+            OIC_LOG_V(ERROR, TAG, "%s cant alloc cred->optionalData.data", __func__);
+            OICFree(cred);
+            return OC_STACK_NO_MEMORY;
+        }
         cred->optionalData.len = chainSize + 1;
     }
     else
@@ -661,7 +666,6 @@ OCStackResult SRPSaveOwnCertChain(OicSecKey_t * cert, OicSecKey_t * key, uint16_
     }
 
     cred->credUsage= (char *)OICCalloc(1, strlen(PRIMARY_CERT)+1 );
-    VERIFY_NON_NULL_RET(TAG, cred->credUsage, ERROR, OC_STACK_NO_MEMORY);
     if (cred->credUsage == NULL)
     {
         OIC_LOG_V(ERROR, TAG, "%s cant alloc credUsage", __func__);
@@ -681,7 +685,6 @@ OCStackResult SRPSaveOwnCertChain(OicSecKey_t * cert, OicSecKey_t * key, uint16_
 
     OicSecKey_t *privateData = &cred->privateData;
     privateData->data = (uint8_t *)OICCalloc(1, key->len);
-    VERIFY_NON_NULL_RET(TAG, privateData->data, ERROR, OC_STACK_NO_MEMORY);
     if (privateData->data == NULL)
     {
         OIC_LOG_V(ERROR, TAG, "%s cant alloc publicData->data", __func__);