Commit 3c37bc53 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Don't crash if a NULL is passed for a "%s" parameter to SDL_SetError(),

 instead replace it with the string "(null)", like glibc's printf() would do.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401175
parent 37c07bd9
...@@ -108,8 +108,10 @@ void SDL_SetError (const char *fmt, ...) ...@@ -108,8 +108,10 @@ void SDL_SetError (const char *fmt, ...)
case 's': case 's':
{ {
int index = error->argc; int index = error->argc;
strncpy((char *)error->args[index].buf, char *str = va_arg(ap, char *);
va_arg(ap, char *), ERR_MAX_STRLEN); if (str == NULL)
str = "(null)";
strncpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN);
error->args[index].buf[ERR_MAX_STRLEN-1] = 0; error->args[index].buf[ERR_MAX_STRLEN-1] = 0;
error->argc++; error->argc++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment