Unix basedir: Don't read past start of array if $PATH has an empty item.

This commit is contained in:
Ryan C. Gordon 2016-04-06 15:01:09 -04:00
parent 91827e7d2a
commit b42025bc9f

View File

@ -106,6 +106,7 @@ static char *getUserDirByUID(void)
} }
// !!! FIXME: This could stand to use CTFileNames ... // !!! FIXME: This could stand to use CTFileNames ...
// !!! FIXME: When we move to SDL2, just use SDL_GetBasePath()?
static char *calcExePath(const char *_argv0) static char *calcExePath(const char *_argv0)
{ {
char *ptr; char *ptr;
@ -137,6 +138,8 @@ static char *calcExePath(const char *_argv0)
start = envr; start = envr;
do do
{ {
while (*start == ':')
start++; // skip empty entries.
ptr = strchr(start, ':'); ptr = strchr(start, ':');
if (ptr) if (ptr)
*ptr = '\0'; *ptr = '\0';