Fix NULL pointer dereferencing in ocstack
authorJamal Haidar <jamal.haidar@samsung.com>
Sat, 20 Jun 2015 06:19:07 +0000 (11:49 +0530)
committerErich Keane <erich.keane@intel.com>
Sun, 21 Jun 2015 01:52:03 +0000 (01:52 +0000)
NULL check guard updated to call presenceResource.handle pointer only
when it is not NULL pointer.

Change-Id: I70f3f17b4a7b5c1f956efb7136458df0cc06f728
Signed-off-by: Jamal Haidar <jamal.haidar@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1371
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/stack/src/ocstack.c

index 415e8fb..9fe41fc 100644 (file)
@@ -2508,12 +2508,12 @@ OCStackResult OCStopPresence()
     if(presenceResource.handle)
     {
         ((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
-    }
 
     // make resource inactive
     result = OCChangeResourceProperty(
             &(((OCResource *) presenceResource.handle)->resourceProperties),
             OC_ACTIVE, 0);
+    }
 
     if(result != OC_STACK_OK)
     {