From f3633c4f99411181668c80ac64fa0c6274ad0226 Mon Sep 17 00:00:00 2001 From: Vitalii Irkha Date: Tue, 10 Sep 2019 19:05:52 +0300 Subject: [PATCH] Svace memory leak fixes 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 Signed-off-by: Sudipto --- resource/csdk/security/provisioning/src/cloud/aclinvite.c | 7 +++++++ resource/csdk/security/provisioning/src/cloud/csr.c | 1 + .../security/provisioning/src/multipleownershiptransfermanager.c | 1 + resource/csdk/security/src/directpairing.c | 1 + 4 files changed, 10 insertions(+) diff --git a/resource/csdk/security/provisioning/src/cloud/aclinvite.c b/resource/csdk/security/provisioning/src/cloud/aclinvite.c index 31eb586..2a04675 100644 --- a/resource/csdk/security/provisioning/src/cloud/aclinvite.c +++ b/resource/csdk/security/provisioning/src/cloud/aclinvite.c @@ -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++) { diff --git a/resource/csdk/security/provisioning/src/cloud/csr.c b/resource/csdk/security/provisioning/src/cloud/csr.c index 3cb44fc..1fc2100 100644 --- a/resource/csdk/security/provisioning/src/cloud/csr.c +++ b/resource/csdk/security/provisioning/src/cloud/csr.c @@ -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)); diff --git a/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c b/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c index 07b492e..71f95d7 100644 --- a/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c +++ b/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c @@ -750,6 +750,7 @@ static OCStackResult SaveSubOwnerPSK(OCProvisionDev_t *selectedDeviceInfo) if (NULL == cred->privateData.data) { OICFree(b64Buf); + DeleteCredList(cred); return res; } diff --git a/resource/csdk/security/src/directpairing.c b/resource/csdk/security/src/directpairing.c index 387df18..ed5aa60 100644 --- a/resource/csdk/security/src/directpairing.c +++ b/resource/csdk/security/src/directpairing.c @@ -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: -- 2.7.4