[Application] handle getcwd return null pointer
authorhyeonseok lee <hs89.lee@samsung.com>
Thu, 14 Sep 2023 08:17:49 +0000 (17:17 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Mon, 18 Sep 2023 07:17:44 +0000 (16:17 +0900)
 - Handle when getcwd return NULL to prevent dereference null pointer

Signed-off-by: hyeonseok lee <hs89.lee@samsung.com>
Applications/SimpleShot/task_runner.cpp

index f58ba7c..d2552f4 100644 (file)
@@ -104,7 +104,9 @@ const std::string getcwd_() {
   const size_t bufsize = 4096;
   char buffer[bufsize];
 
-  return getcwd(buffer, bufsize);
+  char *cwd = getcwd(buffer, bufsize);
+  std::string ret = (cwd == NULL) ? "" : std::string(cwd);
+  return ret;
 }
 } // namespace