This patch fixes the "(error) Possible null pointer dereference:" issues
reported by cppcheck tool in resource/csdk/security/ directory.
Change-Id: I36c41312fe3d78edd43c6c505b875ecbb6ba0dfa
Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2905
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Shilpa Sodani <shilpa.a.sodani@intel.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
OCResourcePayload* resPayload = ((OCDiscoveryPayload*)clientResponse->payload)->resources;
//Verifying if the ID of the sender is an AMS service that this device trusts.
- if(memcmp(context->amsMgrContext->amsDeviceId.id, resPayload->sid,
+ if(resPayload &&
+ memcmp(context->amsMgrContext->amsDeviceId.id, resPayload->sid,
sizeof(context->amsMgrContext->amsDeviceId.id)) != 0)
{
context->retVal = ACCESS_DENIED_AMS_SERVICE_ERROR;
*/
OCStackResult InitPolicyEngine(PEContext_t *context)
{
- context->amsMgrContext = (AmsMgrContext_t *)OICMalloc(sizeof(AmsMgrContext_t));
if(NULL != context)
{
+ context->amsMgrContext = (AmsMgrContext_t *)OICMalloc(sizeof(AmsMgrContext_t));
SetPolicyEngineState(context, AWAITING_REQUEST);
}
if(NULL != context)
{
SetPolicyEngineState(context, STOPPED);
+ OICFree(context->amsMgrContext);
}
- OICFree(context->amsMgrContext);
return;
}