Skip to content

Commit

Permalink
Don't crash if a NULL is passed for a "%s" parameter to SDL_SetError(),
Browse files Browse the repository at this point in the history
 instead replace it with the string "(null)", like glibc's printf() would do.
  • Loading branch information
icculus committed Nov 17, 2005
1 parent 0b8bd70 commit 33aae66
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/SDL_error.c
Expand Up @@ -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++;
}
Expand Down

0 comments on commit 33aae66

Please sign in to comment.