Fix aircon_controller crash issue
authorJee Hyeok Kim <jihyeok13.kim@samsung.com>
Mon, 24 Oct 2016 02:57:14 +0000 (11:57 +0900)
committerJee Hyeok Kim <jihyeok13.kim@samsung.com>
Mon, 24 Oct 2016 06:55:24 +0000 (06:55 +0000)
1. Fix crash issue

Change-Id: I6033e3272ce8f085730e1b579e026ef079bd7097
Signed-off-by: Jee Hyeok Kim <jihyeok13.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13585
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
cloud/samples/client/airconditioner/aircon_controller.cpp

index bc9a929..fa1cd91 100644 (file)
@@ -22,7 +22,7 @@ string         g_uid;
 string         g_accesstoken;
 
 string              g_host;
-OC::OCResource::Ptr g_binaryswitchResource;
+OC::OCResource::Ptr g_binaryswitchResource = nullptr;
 
 void printRepresentation(OCRepresentation rep)
 {
@@ -154,6 +154,12 @@ void onPost(const HeaderOptions & /*headerOptions*/, const OCRepresentation &rep
 
 void turnOnOffSwitch(bool toTurn)
 {
+    if (g_binaryswitchResource == nullptr)
+    {
+        cout << "Binary switch not found" << endl;
+        return;
+    }
+
     OCRepresentation binarySwitch;
     binarySwitch.setValue("value", toTurn);