Fix defects detected by static analysis
authorParkhi <h_w.park@samsung.com>
Mon, 5 Dec 2016 02:21:31 +0000 (11:21 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 7 Dec 2016 09:10:38 +0000 (09:10 +0000)
Change-Id: I9f2fd3a24df5f1394174e71ee561ed02ac8d0769
Signed-off-by: Parkhi <h_w.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15133
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jihun Ha <jihun.ha@samsung.com>
(cherry picked from commit 94ad6508f77f5904de76e85ee30de43b44d738fc)
Reviewed-on: https://gerrit.iotivity.org/gerrit/15135
Reviewed-by: Hemant Mahsky <h.mahsky@samsung.com>
service/easy-setup/enrollee/src/resourcehandler.c

index 6c12afb..450e626 100755 (executable)
@@ -549,7 +549,7 @@ OCRepPayload* constructResponseOfWiFi(char *interface)
     else
     {
         OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
-        OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_WIFI);\r
+        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);