shithub: choc

Download patch

ref: 2550ff5bd989d5b52eabe32c21d8ded4f29b16f9
parent: 72b7843c8f54936f4cfc3b7d1bf0b3b8df5401e4
author: Turo Lamminen <[email protected]>
date: Tue May 15 15:06:51 EDT 2018

d_iwad: Fix memory leak in CheckDirectoryHasIWAD

M_FileCaseExists returns a new string so we must free filename before returning.

--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -492,12 +492,11 @@
     }
 
     probe = M_FileCaseExists(filename);
+    free(filename);
     if (probe != NULL)
     {
         return probe;
     }
-
-    free(filename);
 
     return NULL;
 }