Fix static analysis issues 58/313658/2
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 1 Jul 2024 00:17:17 +0000 (09:17 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 1 Jul 2024 02:18:49 +0000 (11:18 +0900)
Checker:
 - COMPARE_RESULT_OF_NEW

Change-Id: I9c18013118d78e04f10a38868acda3c719c6a2a1
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/aul/launch_with_result.cc

index 25ca3ffbd82762bafa3d66bc5b76e0efd7dbc7d9..03f8acc5a47db1369e30a309cd4741ea55ba5432 100644 (file)
@@ -468,24 +468,23 @@ int __send_request_with_callback(int cmd, const char* appid, bundle* b,
     return AUL_R_ECOMM;
   }
 
-  auto error_info = std::make_unique<ErrorInfo>(seq_num,
-      tizen_base::Bundle(b, true, true), cmd, error_cb, user_data);
-  if (error_info.get() == nullptr) {
-    _E("Failed to create error info");
-    if (reply_cb != nullptr)
-      __reply_list.Pop(seq_num);
-    return AUL_R_ERROR;
-  }
+  try {
+    auto error_info = std::make_unique<ErrorInfo>(seq_num,
+        tizen_base::Bundle(b, true, true), cmd, error_cb, user_data);
+    if (error_info->AddWatch(fd) < 0) {
+      _E("Failed to add resultcb watch");
+      if (reply_cb != nullptr)
+        __reply_list.Pop(seq_num);
+      close(fd);
+      return AUL_R_ERROR;
+    }
 
-  if (error_info->AddWatch(fd) < 0) {
-    _E("Failed to add resultcb watch");
-    if (reply_cb != nullptr)
-      __reply_list.Pop(seq_num);
-    close(fd);
+    error_info.release();
+  } catch (const std::bad_alloc& e) {
+    _E("Exception occurs. error=%s", e.what());
     return AUL_R_ERROR;
   }
 
-  error_info.release();
   return AUL_R_OK;
 }