SDL: fix a possible memory leak in SDL_vasprintf()

From 9b2c70c9c805d39a5f81a66c4a1851ab6cb0c758 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sun, 5 Nov 2023 20:01:02 +0300
Subject: [PATCH] fix a possible memory leak in SDL_vasprintf()

(cherry picked from commit 1a83bf2399c29f3028477225067bf6a106068f08)
---
 src/stdlib/SDL_string.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c
index 7353d459121e..b36fda42d1d6 100644
--- a/src/stdlib/SDL_string.c
+++ b/src/stdlib/SDL_string.c
@@ -1989,6 +1989,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap)
 
         /* Check error code */
         if (retval < 0) {
+            SDL_free(p);
             return retval;
         }
 
@@ -2010,5 +2011,3 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap)
         }
     }
 }
-
-/* vi: set ts=4 sw=4 expandtab: */