[IOT-2361] Perform NULL check before dereference. 61/22361/1
authorSenthil Kumar G S <senthil.gs@samsung.com>
Wed, 30 Aug 2017 15:30:40 +0000 (21:00 +0530)
committerSenthil Kumar G S <senthil.gs@samsung.com>
Thu, 7 Sep 2017 06:51:25 +0000 (06:51 +0000)
Moved NULL checking macro invocation for pointer variable
before it gets dereferenced.

Change-Id: I303e56ae1e856991f44373e06c5adc156515107a
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/22273
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Harish Marappa <h.marappa@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
(cherry picked from commit 578ba07661d943e42762745daaeeaea89fc9604e)

resource/csdk/stack/src/ocpayloadparse.c

index e7a04cd..91f2f01 100644 (file)
@@ -1207,10 +1207,11 @@ static OCStackResult OCParseRepPayload(OCPayload **outPayload, CborValue *root)
     OCRepPayload *temp = NULL;
     OCRepPayload *rootPayload = NULL;
     OCRepPayload *curPayload = NULL;
-    CborValue rootMap = *root;
+    CborValue rootMap;
     VERIFY_PARAM_NON_NULL(TAG, outPayload, "Invalid Parameter outPayload");
     VERIFY_PARAM_NON_NULL(TAG, root, "Invalid Parameter root");
 
+    rootMap = *root;
     *outPayload = NULL;
     if (cbor_value_is_array(root))
     {