From: hyeonseok lee Date: Thu, 14 Sep 2023 08:17:49 +0000 (+0900) Subject: [Application] handle getcwd return null pointer X-Git-Tag: accepted/tizen/8.0/unified/20231005.093407~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e4be190f85858a6f044d2ecaa99a26b90186af5;p=platform%2Fcore%2Fml%2Fnntrainer.git [Application] handle getcwd return null pointer - Handle when getcwd return NULL to prevent dereference null pointer Signed-off-by: hyeonseok lee --- 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