Commit a2b13e585cde7445316724123b051faae2a72c45

Ozkan Sezer 2021-12-02T02:28:24

SDL_iconv_string: avoid memory leak if realloc() fails.

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c
index ec7715f..1a45dba 100644
--- a/src/stdlib/SDL_iconv.c
+++ b/src/stdlib/SDL_iconv.c
@@ -867,6 +867,7 @@ SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf,
                 stringsize *= 2;
                 string = (char *) SDL_realloc(string, stringsize);
                 if (!string) {
+                    SDL_free(oldstring);
                     SDL_iconv_close(cd);
                     return NULL;
                 }