Fix crash when getting not existing theme info 72/240872/3
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 12 Aug 2020 08:44:49 +0000 (17:44 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 18 Aug 2020 04:08:30 +0000 (13:08 +0900)
Change-Id: I095af8c0849827c7ab0e8a7127213e59086d90d1
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/theme/loader/theme_info_loader.cc
test/unit_tests/test_theme_loader.cc

index 8eefe7b..c9a935c 100644 (file)
@@ -134,7 +134,12 @@ std::shared_ptr<ThemeInfo> ThemeInfoLoader::Load(const std::string& id) const {
 
   tizen_base::Bundle reply =
     dbus::RequestBroker::GetInst().SendData(dbus::Command::GET, b);
-  tizen_base::Bundle serialized(reply.GetString(dbus::kCmdDataKey));
+  std::string str = reply.GetString(dbus::kCmdDataKey);
+  if (str.empty()) {
+    LOG(ERROR) << "Failed to load theme info of " << id;
+    return nullptr;
+  }
+  tizen_base::Bundle serialized(str);
   if (serialized.IsEmpty()) {
     LOG(ERROR) << "Failed to load theme info of id: " << id;
     return nullptr;
index bc494ff..3126a78 100644 (file)
@@ -205,6 +205,9 @@ TEST_F(ThemeLoaderTest, Load_N) {
 
   ret = theme_loader_load(loader_handle_, nullptr, &theme_handle);
   EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
+
+  ret = theme_loader_load(loader_handle_, "not_exist_theme", &theme_handle);
+  EXPECT_EQ(ret, THEME_MANAGER_ERROR_IO_ERROR);
 }
 
 TEST_F(ThemeLoaderTest, QueryID) {