mirror of
https://github.com/yawut/SDL.git
synced 2026-08-03 08:50:27 -05:00
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.
This commit is contained in:
parent
58619a0496
commit
d9b15286c8
|
|
@ -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…
Reference in New Issue
Block a user