Skip to content

Commit

Permalink
backfort fix for bug #3739: handle %lu, %li and %ld in SDL_SetError.
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Mar 24, 2018
1 parent 93b0bea commit 4283569
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/SDL_error.c
Expand Up @@ -68,6 +68,17 @@ void SDL_SetError (const char *fmt, ...)
case 0: /* Malformed format string.. */
--fmt;
break;
case 'l':
switch (*fmt++) {
case 0: /* Malformed format string.. */
--fmt;
break;
case 'i': case 'd': case 'u':
error->args[error->argc++].value_l =
va_arg(ap, long);
break;
}
break;
case 'c':
case 'i':
case 'd':
Expand Down Expand Up @@ -139,6 +150,21 @@ char *SDL_GetErrorMsg(char *errstr, int maxlen)
while ( (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) && spot < (tmp+SDL_arraysize(tmp)-2) ) {
*spot++ = *fmt++;
}
if (*fmt == 'l') {
*spot++ = *fmt++;
*spot++ = *fmt++;
*spot++ = '\0';
switch (spot[-2]) {
case 'i': case 'd': case 'u':
len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_l);
if (len > 0) {
msg += len;
maxlen -= len;
}
break;
}
continue;
}
*spot++ = *fmt++;
*spot++ = '\0';
switch (spot[-2]) {
Expand Down
1 change: 1 addition & 0 deletions src/SDL_error_c.h
Expand Up @@ -50,6 +50,7 @@ typedef struct SDL_error {
unsigned char value_c;
#endif
int value_i;
long value_l;
double value_f;
char buf[ERR_MAX_STRLEN];
} args[ERR_MAX_ARGS];
Expand Down

0 comments on commit 4283569

Please sign in to comment.