From: havoc Date: Tue, 23 Mar 2004 07:44:34 +0000 (+0000) Subject: fixed a memory leak if an image file loaded but failed to decode X-Git-Tag: xonotic-v0.1.0preview~5967 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ce23c49782092a6bbe99f1157b450ff17cc35e5d;p=xonotic%2Fdarkplaces.git fixed a memory leak if an image file loaded but failed to decode git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4050 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/image.c b/image.c index fb553d07..4dae89a9 100644 --- a/image.c +++ b/image.c @@ -655,13 +655,18 @@ qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth, for (i = 0;imageformats[i].formatstring;i++) { sprintf (name, imageformats[i].formatstring, basename); - if ((f = FS_LoadFile(name, true)) && (data = imageformats[i].loadfunc(f, matchwidth, matchheight))) + f = FS_LoadFile(name, true); + if (f) { + data = imageformats[i].loadfunc(f, matchwidth, matchheight); Mem_Free(f); - Con_DPrintf("loaded image %s (%dx%d)\n", name, image_width, image_height); - if (developer_memorydebug.integer) - Mem_CheckSentinelsGlobal(); - return data; + if (data) + { + Con_DPrintf("loaded image %s (%dx%d)\n", name, image_width, image_height); + if (developer_memorydebug.integer) + Mem_CheckSentinelsGlobal(); + return data; + } } } if (complain)