]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed a memory leak if an image file loaded but failed to decode
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 23 Mar 2004 07:44:34 +0000 (07:44 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 23 Mar 2004 07:44:34 +0000 (07:44 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4050 d7cf8633-e32d-0410-b094-e92efae38249

image.c

diff --git a/image.c b/image.c
index fb553d07d2a0e61ed233814d7341fa0a1ef0cf00..4dae89a9a9880087a2ba99ac06c45205b70c3b8a 100644 (file)
--- 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)