From: divverent Date: Sun, 20 Jun 2010 15:26:32 +0000 (+0000) Subject: Catch bad pointers when loading corrupt TGAs X-Git-Tag: xonotic-v0.1.0preview~414 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=18d4564c2b0c472046cd601d44e8e32af2f1b043;p=xonotic%2Fdarkplaces.git Catch bad pointers when loading corrupt TGAs git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10240 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=19f4a480fcbe200d55f810915e0629e40e892ad6 --- diff --git a/image.c b/image.c index ccc59f2e..3c061de1 100644 --- a/image.c +++ b/image.c @@ -609,6 +609,13 @@ unsigned char *LoadTGA_BGRA (const unsigned char *f, int filesize) *pixbufi++ = palettei[*fin++]; } } + + if (x != image_width) + { + // pixbufi is useless now + Con_Printf("LoadTGA: corrupt file\n"); + break; + } } break; case 10: @@ -657,6 +664,13 @@ unsigned char *LoadTGA_BGRA (const unsigned char *f, int filesize) } } } + + if (x != image_width) + { + // pixbufi is useless now + Con_Printf("LoadTGA: corrupt file\n"); + break; + } } } else @@ -703,6 +717,13 @@ unsigned char *LoadTGA_BGRA (const unsigned char *f, int filesize) } } } + + if (x != image_width) + { + // pixbufi is useless now + Con_Printf("LoadTGA: corrupt file\n"); + break; + } } } break;