From 44809db51775b6bed0217f92b7153fa8685e568a Mon Sep 17 00:00:00 2001 From: Oleksii Beketov Date: Tue, 10 Sep 2019 15:11:00 +0300 Subject: [PATCH] Memleak fix https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/9ea7c80e82baee3f896d31f31397e8d6b92afa25 (cherry-picked from 9ea7c80e82baee3f896d31f31397e8d6b92afa25) Change-Id: Id194ae5ee25c1fb48c4a177836dec2a138d0869f Signed-off-by: Sudipto --- resource/csdk/security/provisioning/src/secureresourceprovider.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/resource/csdk/security/provisioning/src/secureresourceprovider.c b/resource/csdk/security/provisioning/src/secureresourceprovider.c index b93fc0a..af5ecf9 100644 --- a/resource/csdk/security/provisioning/src/secureresourceprovider.c +++ b/resource/csdk/security/provisioning/src/secureresourceprovider.c @@ -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__); -- 2.7.4