From 8b2792228fd80186a99ec5cea0dac30c00086dfc Mon Sep 17 00:00:00 2001 From: Jee Hyeok Kim Date: Mon, 24 Oct 2016 11:57:14 +0900 Subject: [PATCH] Fix aircon_controller crash issue 1. Fix crash issue Change-Id: I6033e3272ce8f085730e1b579e026ef079bd7097 Signed-off-by: Jee Hyeok Kim Reviewed-on: https://gerrit.iotivity.org/gerrit/13585 Tested-by: jenkins-iotivity --- cloud/samples/client/airconditioner/aircon_controller.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cloud/samples/client/airconditioner/aircon_controller.cpp b/cloud/samples/client/airconditioner/aircon_controller.cpp index bc9a929..fa1cd91 100644 --- a/cloud/samples/client/airconditioner/aircon_controller.cpp +++ b/cloud/samples/client/airconditioner/aircon_controller.cpp @@ -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); -- 2.7.4