diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c index e0c63238..66b6fa17 100644 --- a/code/sys/sys_unix.c +++ b/code/sys/sys_unix.c @@ -346,6 +346,10 @@ void Sys_ListFilteredFiles( const char *basedir, char *subdirs, char *filter, ch return; } + if ( basedir[0] == '\0' ) { + return; + } + if (strlen(subdirs)) { Com_sprintf( search, sizeof(search), "%s/%s", basedir, subdirs ); } @@ -425,6 +429,11 @@ char **Sys_ListFiles( const char *directory, const char *extension, char *filter return listCopy; } + if ( directory[0] == '\0' ) { + *numfiles = 0; + return NULL; + } + if ( !extension) extension = ""; diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index e40caaa0..d5e1c637 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -483,6 +483,10 @@ void Sys_ListFilteredFiles( const char *basedir, char *subdirs, char *filter, ch return; } + if ( basedir[0] == '\0' ) { + return; + } + if (strlen(subdirs)) { Com_sprintf( search, sizeof(search), "%s\\%s\\*", basedir, subdirs ); } @@ -584,6 +588,11 @@ char **Sys_ListFiles( const char *directory, const char *extension, char *filter return listCopy; } + if ( directory[0] == '\0' ) { + *numfiles = 0; + return NULL; + } + if ( !extension) { extension = ""; }