From ee51d594a179fb47ebf2e7ee36024cde6dbeb284 Mon Sep 17 00:00:00 2001 From: Giulio Moro Date: Fri, 31 May 2024 18:58:45 -0500 Subject: [PATCH] default_main: prevent segmentation fault if accessing context->projectName when the project is running from PATH and therefore strrchr returns NULL --- core/default_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/default_main.cpp b/core/default_main.cpp index ae2175edc..79205a480 100644 --- a/core/default_main.cpp +++ b/core/default_main.cpp @@ -48,7 +48,8 @@ int main(int argc, char *argv[]) settings->cleanup = cleanup; if(argc > 0 && argv[0]) { - settings->projectName = strrchr(argv[0], '/') + 1; + char* nameWithSlash = strrchr(argv[0], '/'); + settings->projectName = nameWithSlash ? nameWithSlash + 1 : argv[0]; } while (1) {