[IOT-2678] Adding Null check to fix crash
authorSushil Yadav <sushil.ky@samsung.com>
Thu, 14 Sep 2017 11:42:48 +0000 (17:12 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 15 Sep 2017 12:58:21 +0000 (12:58 +0000)
Change-Id: I360d5ffbe468f16e40a1f1f3171edd1c0d23e94d
Signed-off-by: Sushil Yadav <sushil.ky@samsung.com>
resource/csdk/stack/src/ocstack.c

index a5e83fa..3c80031 100644 (file)
@@ -3975,6 +3975,12 @@ OCStackResult OC_CALL OCStartPresence(const uint32_t ttl)
 {
     OIC_LOG(INFO, TAG, "Entering OCStartPresence");
     uint8_t tokenLength = CA_MAX_TOKEN_LEN;
+    if (NULL == presenceResource.handle)
+    {
+        OIC_LOG(ERROR, TAG, "Invalid Presence Resource Handle: Not Initialized");
+        return OC_STACK_ERROR;
+    }
+
     OCChangeResourceProperty(
             &(((OCResource *)presenceResource.handle)->resourceProperties),
             OC_ACTIVE, 1);