Commit 0d673844acfc436577759636e76441baaa030ca7

Sam Lantinga 2014-06-21T11:52:53

Fixed bug 2596 - SDL_SetError fails on on NULL on systems with vsnprintf sfalexrog On systems with vsnprintf call SDL_SetError fails when passed a NULL as an argument. SDL's implementation checks for NULL (as seen in the commit: https://hg.libsdl.org/SDL/rev/835403a6aec8), but system implementation may crash.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c
index dd0eab1..8428586 100644
--- a/src/stdlib/SDL_string.c
+++ b/src/stdlib/SDL_string.c
@@ -1276,6 +1276,9 @@ SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_
 #ifdef HAVE_VSNPRINTF
 int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
 {
+    if (!fmt) {
+        fmt = "";
+    }
     return vsnprintf(text, maxlen, fmt, ap);
 }
 #else