From 409f1fc026e5aedad267b3bfcd82c4969d8c256e Mon Sep 17 00:00:00 2001 From: jdolan Date: Sat, 29 Jun 2013 11:05:49 -0400 Subject: [PATCH] Failure to load PCX/BMP/TGA should not result in a fatal error. Check the existence of these files first, if the file does not exist, simply return. This way we'll still blow up on malformed images, which is less annoying. --- plugins/image/image.h | 1 + plugins/image/lbmlib.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/plugins/image/image.h b/plugins/image/image.h index c6a054f..5351390 100644 --- a/plugins/image/image.h +++ b/plugins/image/image.h @@ -49,6 +49,7 @@ extern _QERFileSystemTable g_FileSystemTable; void LoadJPG( const char *filename, unsigned char **pic, int *width, int *height ); #define Error g_FuncTable.m_pfnError +#define vfsGetFileCount g_FileSystemTable.m_pfnGetFileCount #define vfsLoadFile g_FileSystemTable.m_pfnLoadFile #define vfsFreeFile g_FileSystemTable.m_pfnFreeFile diff --git a/plugins/image/lbmlib.cpp b/plugins/image/lbmlib.cpp index e4d54e1..7ad1311 100644 --- a/plugins/image/lbmlib.cpp +++ b/plugins/image/lbmlib.cpp @@ -743,6 +743,10 @@ void LoadImage( const char *name, byte ** pic, int *width, int *height ){ return; } + if ( vfsGetFileCount( name, 0 ) == 0 ) { + return; + } + if ( !g_ascii_strcasecmp( name + len - 4, ".tga" ) ) { LoadTGA( name, pic, width, height ); }