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:
parent
37c07bd99d
commit
3c37bc53e6
1 changed files with 4 additions and 2 deletions
|
@ -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++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue