Modify the potential errors 93/7793/3
authorJaehong Jo <jaehong.jo@samsung.com>
Fri, 15 Apr 2016 01:55:05 +0000 (10:55 +0900)
committerJon A. Cruz <jon@joncruz.org>
Wed, 20 Apr 2016 14:26:09 +0000 (14:26 +0000)
Added null check

Change-Id: I007b131450e672091d5783c82b56d6a5151439ef
Signed-off-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7793
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
resource/csdk/stack/src/occollection.c
resource/csdk/stack/src/ocstack.c

index 551cdd4..896621f 100755 (executable)
@@ -287,7 +287,6 @@ HandleBatchInterface(OCEntityHandlerRequest *ehRequest)
     }
 
     OCResource * collResource = (OCResource *) ehRequest->resource;
-    OCChildResource *tempChildResource = NULL;
 
     OCRepPayload* payload = OCRepPayloadCreate();
     if (!payload)
@@ -310,8 +309,8 @@ HandleBatchInterface(OCEntityHandlerRequest *ehRequest)
 
     if (stackRet == OC_STACK_OK)
     {
-        tempChildResource = collResource->rsrcChildResourcesHead;
-
+        OCChildResource *tempChildResource = (collResource) ? collResource->rsrcChildResourcesHead
+                                                              : NULL;
         while(tempChildResource)
         {
             OCResource* tempRsrcResource = tempChildResource->rsrcResource;
@@ -323,8 +322,8 @@ HandleBatchInterface(OCEntityHandlerRequest *ehRequest)
                 // is ehRequest->resource
                 ehRequest->resource = (OCResourceHandle) tempRsrcResource;
 
-                OCEntityHandlerResult ehResult = tempRsrcResource->entityHandler(OC_REQUEST_FLAG, ehRequest,
-                                                        tempRsrcResource->entityHandlerCallbackParam);
+                OCEntityHandlerResult ehResult = tempRsrcResource->entityHandler(OC_REQUEST_FLAG,
+                                           ehRequest, tempRsrcResource->entityHandlerCallbackParam);
 
                 // The default collection handler is returning as OK
                 if (stackRet != OC_STACK_SLOW_RESOURCE)
index c0219d0..920d5dd 100644 (file)
@@ -1676,6 +1676,11 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
     {
         serverRequest.reqTotalSize = requestInfo->info.payloadSize;
         serverRequest.payload = (uint8_t *) OICMalloc(requestInfo->info.payloadSize);
+        if (!serverRequest.payload)
+        {
+            OIC_LOG(ERROR, TAG, "Allocation for payload failed.");
+            return;
+        }
         memcpy (serverRequest.payload, requestInfo->info.payload,
                 requestInfo->info.payloadSize);
     }
@@ -2036,7 +2041,7 @@ OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
     VERIFY_SUCCESS(result, OC_STACK_OK);
 
 #ifdef TCP_ADAPTER
-    CARegisterKeepAliveHandler(HandleKeepAliveConnCB, HandleKeepAliveDisconnCB);
+    CARegisterKeepAliveHandler(HandleKeepAliveConnCB);
 #endif
 
 #ifdef WITH_PRESENCE