From: Michal Kolodziej Date: Thu, 15 Sep 2016 13:36:23 +0000 (+0200) Subject: [Iotcon] Fix bug when options is null in RemoteResourceFromJson X-Git-Tag: submit/tizen/20160920.235405~8^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a6bcb7f232f5eba16f0b2fa9e0fd773e4951f9c;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Iotcon] Fix bug when options is null in RemoteResourceFromJson [Details] Fixed bug which caused fail on assert in picojson::get method for array. Function needed an array and value provided was null. Change-Id: I3942fb65e1f29dbe90b18f5b8a5227afeffe9478 Signed-off-by: Michal Kolodziej --- diff --git a/src/iotcon/iotcon_utils.cc b/src/iotcon/iotcon_utils.cc index 14362364..fce0426d 100644 --- a/src/iotcon/iotcon_utils.cc +++ b/src/iotcon/iotcon_utils.cc @@ -543,14 +543,17 @@ common::TizenResult IotconUtils::RemoteResourceFromJson(const picojson::object& LogAndReturnTizenError(res, ("creating handle failed")); } - // options is optional nullable. if it's not present, just ignore it + // options is optional nullable. if it's not present or is null, just ignore it auto options_it = source.find(kOptions); if (source.end() != options_it) { - const auto& options_array = options_it->second.get(); iotcon_options_h options = nullptr; - res = IotconUtils::OptionsFromJson(options_array, &options); - if (!res) { - return res; + // if array supplied, set it. Other cases just clear options with nullptr + if (options_it->second.is()) { + const auto& options_array = options_it->second.get(); + res = IotconUtils::OptionsFromJson(options_array, &options); + if (!res) { + return res; + } } res = IotconUtils::ConvertIotconError(iotcon_remote_resource_set_options((*ptr)->handle, options)); if (!res) {