From 8e4be190f85858a6f044d2ecaa99a26b90186af5 Mon Sep 17 00:00:00 2001 From: hyeonseok lee Date: Thu, 14 Sep 2023 17:17:49 +0900 Subject: [PATCH] [Application] handle getcwd return null pointer - Handle when getcwd return NULL to prevent dereference null pointer Signed-off-by: hyeonseok lee --- Applications/SimpleShot/task_runner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Applications/SimpleShot/task_runner.cpp b/Applications/SimpleShot/task_runner.cpp index f58ba7c..d2552f4 100644 --- a/Applications/SimpleShot/task_runner.cpp +++ b/Applications/SimpleShot/task_runner.cpp @@ -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 -- 2.7.4