Fix create string with NULL crash 05/203605/1
authorhyunho <hhstark.kang@samsung.com>
Tue, 16 Apr 2019 07:05:44 +0000 (16:05 +0900)
committerhyunho <hhstark.kang@samsung.com>
Tue, 16 Apr 2019 07:05:44 +0000 (16:05 +0900)
Change-Id: I88ea49bfaa71b8f96275fae10d3dd78d6e68b43a
Signed-off-by: hyunho <hhstark.kang@samsung.com>
notification-ex/stub.cc

index 5082fc3ebafc964809bb7a9b9b24c636a58a28b5..041a8a05401607c5d9ab671f20f7429c74c03e96 100644 (file)
@@ -1951,10 +1951,14 @@ extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
 
+  string receiver_group_str = "";
+  if (receiver_group)
+    receiver_group_str = string(receiver_group);
+
   ManagerStub* stub = new (std::nothrow) ManagerStub(
       unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
       unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())),
-      receiver_group);
+      receiver_group_str);
   if (stub == nullptr) {
     LOGE("Fail to create manager");
     return NOTI_EX_ERROR_IO_ERROR;
@@ -2322,7 +2326,7 @@ extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
     list<shared_ptr<item::AbstractItem>> notiList;
     for (int i = 0; i < count; i++) {
       Handle* item = static_cast<Handle*>(noti_list[i]);
-      notiList.emplace_back(item->GetPtr());
+      notiList.push_back(item->GetPtr());
     }
     *request_id = stub->Post(notiList);
   } catch (Exception &ex) {
@@ -2545,7 +2549,11 @@ extern "C" EXPORT_API int noti_ex_action_visibility_create(
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
 
-  auto* p = new (std::nothrow) VisibilityAction(extra);
+  string extra_str = "";
+  if (extra != NULL)
+    extra_str = string(extra);
+
+  auto* p = new (std::nothrow) VisibilityAction(extra_str);
   if (p == nullptr) {
     LOGE("Out-of-memory");
     return NOTI_EX_ERROR_OUT_OF_MEMORY;