From 5297b46dcb238b0e738e2bad7ea5b34413d361a8 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Sun, 8 Nov 2020 06:25:13 +0000 Subject: [PATCH] image: Check if file exists first to allow early out and avoid a slower codepath git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13040 d7cf8633-e32d-0410-b094-e92efae38249 --- image.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/image.c b/image.c index ceecd249..9f07ce60 100644 --- a/image.c +++ b/image.c @@ -1084,8 +1084,7 @@ unsigned char *loadimagepixelsbgra (const char *filename, qbool complain, qbool for (format = firstformat;format->formatstring;format++) { dpsnprintf (name, sizeof(name), format->formatstring, basename); - f = FS_LoadFile(name, tempmempool, true, &filesize); - if (f) + if(FS_FileExists(name) && (f = FS_LoadFile(name, tempmempool, true, &filesize)) != NULL) { mymiplevel = miplevel ? *miplevel : 0; image_width = 0; -- 2.39.2