mirror of https://github.com/encounter/SDL.git
Fixed crash when printing NULL wide character string
This commit is contained in:
parent
754286c61c
commit
f487d63a6b
|
@ -1899,10 +1899,15 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt,
|
||||||
{
|
{
|
||||||
/* In practice this is used on Windows for WCHAR strings */
|
/* In practice this is used on Windows for WCHAR strings */
|
||||||
wchar_t *wide_arg = va_arg(ap, wchar_t *);
|
wchar_t *wide_arg = va_arg(ap, wchar_t *);
|
||||||
char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg));
|
if (wide_arg) {
|
||||||
info.pad_zeroes = SDL_FALSE;
|
char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg));
|
||||||
len = SDL_PrintString(text, left, &info, arg);
|
info.pad_zeroes = SDL_FALSE;
|
||||||
SDL_free(arg);
|
len = SDL_PrintString(text, left, &info, arg);
|
||||||
|
SDL_free(arg);
|
||||||
|
} else {
|
||||||
|
info.pad_zeroes = SDL_FALSE;
|
||||||
|
len = SDL_PrintString(text, left, &info, NULL);
|
||||||
|
}
|
||||||
done = SDL_TRUE;
|
done = SDL_TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue