diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 0c97cc0248..9f434a46cb 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -2201,6 +2201,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) /* Check error code */ if (retval < 0) { + SDL_free(p); return retval; }