From 19f4a480fcbe200d55f810915e0629e40e892ad6 Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 20 Jun 2010 15:26:32 +0000 Subject: [PATCH] Catch bad pointers when loading corrupt TGAs git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10240 d7cf8633-e32d-0410-b094-e92efae38249 --- image.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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; -- 2.39.2