[IOT-2319] Discovery Request fix
authorOleksandr Dmytrenko <o.dmytrenko@samsung.com>
Fri, 19 May 2017 14:21:06 +0000 (17:21 +0300)
committerRandeep Singh <randeep.s@samsung.com>
Sat, 20 May 2017 03:09:20 +0000 (03:09 +0000)
[CS][Csdk][Sample App] Discovery Request Crashed fix

Change-Id: Iffc7b61fce57dfab706122bc5649d3fd65ab0daa
Signed-off-by: Oleksandr Dmytrenko <o.dmytrenko@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20151
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: dongik Lee <dongik.lee@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/provisioning/sample/cloud/cloudDiscovery.c

index 4e8878a..977d151 100644 (file)
@@ -58,8 +58,17 @@ static void clearData()
  */
 static void parseClientResponse(OCClientResponse * clientResponse)
 {
-    OCResourcePayload* res = ((OCDiscoveryPayload*)clientResponse->payload)->resources;
+    OIC_LOG_V(DEBUG, TAG, "IN: %s",__func__);
 
+    if (!clientResponse || !clientResponse->payload)
+    {
+        OIC_LOG_V(WARNING, TAG, "OUT: %s: %s is NULL",__func__, 
+            !clientResponse ? "clientResponse" : "clientResponse->payload");
+        return;
+    }
+
+    OCResourcePayload* res = ((OCDiscoveryPayload*)clientResponse->payload)->resources;
+    
     while (res)
     {
         char *uri = res->uri;
@@ -100,6 +109,7 @@ static void parseClientResponse(OCClientResponse * clientResponse)
         next:
         res = res->next;
     }
+    OIC_LOG_V(DEBUG, TAG, "OUT: %s",__func__);
 }
 
 /**