[IOT-2675] Fix occlient sample app crash 31/22331/6
authorkoushik.girijala <g.koushik@samsung.com>
Wed, 6 Sep 2017 09:27:23 +0000 (14:57 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 8 Sep 2017 09:22:50 +0000 (09:22 +0000)
NULL check added

Change-Id: I36ccb505024c036921c906efaf9443892ac7d5ba
Signed-off-by: koushik.girijala <g.koushik@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/22331
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Veeraj Khokale <veeraj.sk@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp

index db7bc32..6bf3880 100644 (file)
@@ -674,6 +674,12 @@ int InitIntrospectionPayload(OCClientResponse * clientResponse)
     std::ostringstream query;
     std::string introspectionPayloadUrl;
     OCRepPayload *introspectionInfo = (OCRepPayload*)clientResponse->payload;
+    if (NULL == introspectionInfo)
+    {
+        OIC_LOG(ERROR, TAG, "\nFailed to get introspection info from NULL payload");
+        return OC_STACK_ERROR;
+    }
+
     OCRepPayloadValue *value = introspectionInfo->values;
 
     while (value)
@@ -1226,7 +1232,7 @@ int main(int argc, char* argv[])
     }
 
 #ifdef SECURED
-    // Set callbacks for handling pin display  
+    // Set callbacks for handling pin display
     if (OC_STACK_OK != SetDisplayPinWithContextCB(DisplayPinCB, NULL))
     {
         OIC_LOG(ERROR, TAG, "Failed to set display pin callback");
@@ -1234,7 +1240,7 @@ int main(int argc, char* argv[])
     }
 
     SetClosePinDisplayCB(ClosePinDisplayCB);
-    
+
     // Specify the type and length of the pin that will be generated upon request
     if (OC_STACK_OK != SetRandomPinPolicy(8, NUM_PIN))
     {