From: Jaehong Jo Date: Fri, 15 Apr 2016 01:55:05 +0000 (+0900) Subject: Modify the potential errors X-Git-Tag: 1.2.0+RC1~398 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3aa88cbae9b582877d5dce1dbddbc7f99838f3e5;p=platform%2Fupstream%2Fiotivity.git Modify the potential errors Added null check Change-Id: I007b131450e672091d5783c82b56d6a5151439ef Signed-off-by: Jaehong Jo Reviewed-on: https://gerrit.iotivity.org/gerrit/7793 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- diff --git a/resource/csdk/stack/src/occollection.c b/resource/csdk/stack/src/occollection.c index 551cdd4..896621f 100755 --- a/resource/csdk/stack/src/occollection.c +++ b/resource/csdk/stack/src/occollection.c @@ -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) diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index c0219d0..920d5dd 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -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