From a6ecc778fcf7bfe9355802510a581ab010012c08 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 8 Jun 2023 22:58:12 +0300 Subject: [PATCH] filesystem: dir: fix FS_FixFileCase when empty string is passed. Always append slash to searchpath. --- filesystem/dir.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/filesystem/dir.c b/filesystem/dir.c index 8e9c3b6f..0612d3da 100644 --- a/filesystem/dir.c +++ b/filesystem/dir.c @@ -290,6 +290,10 @@ qboolean FS_FixFileCase( dir_t *dir, const char *path, char *dst, const size_t l if( !FS_AppendToPath( dst, &i, len, dir->name, path, "init" )) return false; + // nothing to fix + if( !COM_CheckStringEmpty( path )) + return true; + for( prev = path, next = Q_strchrnul( prev, '/' ); ; prev = next + 1, next = Q_strchrnul( prev, '/' )) @@ -464,8 +468,12 @@ void FS_InitDirectorySearchpath( searchpath_t *search, const char *path, int fla { memset( search, 0, sizeof( searchpath_t )); - Q_strncpy( search->filename, path, sizeof( search->filename )); - search->type = SEARCHPATH_PLAIN; + Q_strncpy( search->filename, path, sizeof( search->filename ) - 1 ); + COM_PathSlashFix( search->filename ); + + if( !Q_stricmp( COM_FileExtension( path ), "pk3dir" )) + search->type = SEARCHPATH_PK3DIR; + else search->type = SEARCHPATH_PLAIN; search->flags = flags; search->pfnPrintInfo = FS_PrintInfo_DIR; search->pfnClose = FS_Close_DIR;