From 4ea0eebfe5eb13945ea0689349185bb0b68e3c1b Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 8 Apr 2018 20:52:19 -0500 Subject: [PATCH] Fix nullptr dereference in front of nullptr check in FS_CheckPak0 Found using LLVM sanitizer. Reported by Dominic "lonkamikaze" Fandrey and David "devnexen" CARLIER. --- code/qcommon/files.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/qcommon/files.c b/code/qcommon/files.c index 16869afc..e5d91671 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -3458,17 +3458,17 @@ static void FS_CheckPak0( void ) { searchpath_t *path; pack_t *curpack; + const char *pakBasename; qboolean founddemo = qfalse; unsigned int foundPak = 0, foundTA = 0; for( path = fs_searchpaths; path; path = path->next ) { - const char* pakBasename = path->pack->pakBasename; - if(!path->pack) continue; curpack = path->pack; + pakBasename = curpack->pakBasename; if(!Q_stricmpn( curpack->pakGamename, "demoq3", MAX_OSPATH ) && !Q_stricmpn( pakBasename, "pak0", MAX_OSPATH ))