# HG changeset patch # User Ryan C. Gordon # Date 1132196687 0 # Node ID f69f4d25fb200910fa7e9edf57a520366e6e707c # Parent f84c6f1397cd26a4d3d51d495d84f40dc7755419 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. diff -r f84c6f1397cd -r f69f4d25fb20 src/SDL_error.c --- a/src/SDL_error.c Thu Nov 17 02:35:15 2005 +0000 +++ b/src/SDL_error.c Thu Nov 17 03:04:47 2005 +0000 @@ -108,8 +108,10 @@ 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++; }