From 0441d74e7845e58f8d86e695a029520fc669e151 Mon Sep 17 00:00:00 2001 From: Parkhi Date: Mon, 5 Dec 2016 11:21:31 +0900 Subject: [PATCH] Fix defects detected by static analysis Change-Id: I9f2fd3a24df5f1394174e71ee561ed02ac8d0769 Signed-off-by: Parkhi Reviewed-on: https://gerrit.iotivity.org/gerrit/15133 Reviewed-by: Uze Choi Tested-by: jenkins-iotivity Reviewed-by: Jihun Ha (cherry picked from commit 94ad6508f77f5904de76e85ee30de43b44d738fc) Reviewed-on: https://gerrit.iotivity.org/gerrit/15135 Reviewed-by: Hemant Mahsky --- service/easy-setup/enrollee/src/resourcehandler.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/service/easy-setup/enrollee/src/resourcehandler.c b/service/easy-setup/enrollee/src/resourcehandler.c index 6c12afb..450e626 100755 --- a/service/easy-setup/enrollee/src/resourcehandler.c +++ b/service/easy-setup/enrollee/src/resourcehandler.c @@ -549,7 +549,7 @@ OCRepPayload* constructResponseOfWiFi(char *interface) else { OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT); - OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_WIFI); + OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_WIFI); } size_t dimensions[MAX_REP_ARRAY_DEPTH] = {gWiFiResource.numMode, 0, 0}; @@ -945,6 +945,11 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest) size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {3, 0, 0}; char **interfaces = (char **)OICMalloc(3 * sizeof(char*)); + if(!interfaces) + { + OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload"); + return NULL; + } interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT); interfaces[1] = OICStrdup(OC_RSRVD_INTERFACE_LL); @@ -954,6 +959,11 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest) size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {2, 0, 0}; char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*)); + if(!resourceTypes) + { + OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload"); + return NULL; + } resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_PROV); resourceTypes[1] = OICStrdup(OC_RSRVD_ES_RES_TYPE_COL); -- 2.7.4