From b42025bc9f1fe51edb53659af015ea295907522b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 6 Apr 2016 15:01:09 -0400 Subject: [PATCH] Unix basedir: Don't read past start of array if $PATH has an empty item. --- Sources/Engine/Base/Unix/UnixFileSystem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/Engine/Base/Unix/UnixFileSystem.cpp b/Sources/Engine/Base/Unix/UnixFileSystem.cpp index 871dc46..08683d0 100644 --- a/Sources/Engine/Base/Unix/UnixFileSystem.cpp +++ b/Sources/Engine/Base/Unix/UnixFileSystem.cpp @@ -106,6 +106,7 @@ static char *getUserDirByUID(void) } // !!! FIXME: This could stand to use CTFileNames ... +// !!! FIXME: When we move to SDL2, just use SDL_GetBasePath()? static char *calcExePath(const char *_argv0) { char *ptr; @@ -137,6 +138,8 @@ static char *calcExePath(const char *_argv0) start = envr; do { + while (*start == ':') + start++; // skip empty entries. ptr = strchr(start, ':'); if (ptr) *ptr = '\0';