From a4a27bc49fa01ae459de55492ca356ae4a1ddd18 Mon Sep 17 00:00:00 2001 From: Diordany van Hemert Date: Mon, 25 Dec 2023 01:02:50 +0100 Subject: [PATCH] Check if the requested game exists --- Quake/common.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Quake/common.c b/Quake/common.c index 5e32afa6b..9ea6a1d49 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -2161,6 +2161,7 @@ static void COM_Game_f (void) { if (Cmd_Argc() > 1) { + char newgamedir[MAX_OSPATH]; const char *p = Cmd_Argv(1); const char *p2 = Cmd_Argv(2); searchpath_t *search; @@ -2189,6 +2190,14 @@ static void COM_Game_f (void) } } + q_strlcpy (newgamedir, va("%s/%s", com_basedir, p), sizeof(newgamedir)); + + if (Sys_FileType(newgamedir) != FS_ENT_DIRECTORY) + { + Con_Printf("The game \"%s\" couldn't be found.\n", p); + return; + } + if (!q_strcasecmp(p, COM_SkipPath(com_gamedir))) //no change { if (com_searchpaths->path_id > 1) { //current game not id1