atrace-helper: Fix an uncatched exception 84/318684/1 accepted/tizen_unified_x_asan accepted/tizen/unified/20250124.105412 accepted/tizen/unified/x/20250125.012756 accepted/tizen/unified/x/asan/20250211.003203
authorSung-hun Kim <sfoon.kim@samsung.com>
Wed, 22 Jan 2025 06:16:25 +0000 (15:16 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Wed, 22 Jan 2025 06:16:25 +0000 (15:16 +0900)
The topmost function can raise std::bad_function_call exception.
Due to the ease of exception handling, the main function handles the exception.
This patch fixes a coverity issue (issue number: 1841863).

Change-Id: If70beacd705adea1d3300b02632b025bc00ae30d
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
atrace-helper/main.cc

index 6079c00f93e9110f7ded4066e37598617dc629da..85613863119deb4ef0529f3eae064ca8ad572bc0 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <functional>
 
 #include <memory>
 #include <set>
@@ -126,7 +127,11 @@ int main(int argc, char** argv) {
   signal(SIGINT, on_exit);
   signal(SIGTERM, on_exit);
 
-  prog->RunAndPrintJson(out_stream);
+  try {
+    prog->RunAndPrintJson(out_stream);
+  } catch (std::bad_function_call &e) {
+    fprintf(stderr, "Exception: %s\n", e.what());
+  }
   fclose(out_stream);
 
   if (dump_to_file)