Commit ea152532204a4f5d9d4ccde173f2532a80493ad8

pionere 2022-05-18T17:23:26

fix GetNearbyFilename - fix memory leak due to variable 'base' - fix usage of uninitialized variable (path)

diff --git a/test/testutils.c b/test/testutils.c
index 3bb2b9c..fa21fe2 100644
--- a/test/testutils.c
+++ b/test/testutils.c
@@ -35,15 +35,18 @@ GetNearbyFilename(const char *file)
         path = SDL_malloc(len);
 
         if (path == NULL) {
+            SDL_free(base);
             SDL_OutOfMemory();
             return NULL;
         }
 
         SDL_snprintf(path, len, "%s%s%s", base, pathsep, file);
-    }
-
-    if (base) {
         SDL_free(base);
+    } else {
+        path = SDL_strdup(file);
+        if (path == NULL) {
+            SDL_OutOfMemory();
+        }
     }
 
     return path;