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
This commit is contained in:
Ryan C. Gordon 2005-11-17 03:04:47 +00:00
parent 37c07bd99d
commit 3c37bc53e6

View file

@ -108,8 +108,10 @@ void SDL_SetError (const char *fmt, ...)
case 's':
{
int index = error->argc;
strncpy((char *)error->args[index].buf,
va_arg(ap, char *), ERR_MAX_STRLEN);
char *str = va_arg(ap, char *);
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->argc++;
}