Fix null reference bug 81/224781/1
authorhyunho <hhstark.kang@samsung.com>
Thu, 13 Feb 2020 04:51:05 +0000 (13:51 +0900)
committerhyunho <hhstark.kang@samsung.com>
Thu, 13 Feb 2020 04:51:36 +0000 (13:51 +0900)
Change-Id: Ia53244120dac72e6f4357d664078fdb4c7ee4292
Signed-off-by: hyunho <hhstark.kang@samsung.com>
watchface-complication/complication.cc

index bd70ee5..8c5e0cd 100644 (file)
@@ -721,7 +721,7 @@ int Complication::SendDataUpdateRequest(bool launch_option) {
     return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
   }
 
-  const char* context_data_raw = "";
+  std::string context_data_raw = "";
   bool emit_ret = false;
   std::string provider_appid = DBManager::GetProviderAppId(
       impl_->cur_provider_id_.c_str());
@@ -743,8 +743,8 @@ int Complication::SendDataUpdateRequest(bool launch_option) {
 
   if (impl_->context_data_ != nullptr) {
     try {
-      context_data_raw = reinterpret_cast<const char*>(
-          impl_->context_data_->ToRaw().first.get());
+      context_data_raw = std::string(reinterpret_cast<const char*>(
+          impl_->context_data_->ToRaw().first.get()));
     } catch (const std::bad_alloc &ba) {
       LOGE("Exception bad_alloc");
       return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
@@ -761,7 +761,7 @@ int Complication::SendDataUpdateRequest(bool launch_option) {
                   util::GetAppId().c_str(),
                   impl_->complication_id_,
                   impl_->cur_type_,
-                  context_data_raw));
+                  context_data_raw.c_str()));
   if (!emit_ret)
     return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;