[CRT] Fix cvt to not overflow the buffer on NAN/INF

Fixes crash in msvcrt_winetest printf
This commit is contained in:
Timo Kreuzer 2025-02-03 11:06:44 +02:00
parent 4a63e19e47
commit 166d83b206

View file

@ -48,6 +48,21 @@ static char *cvt(double arg, int ndigits, int *decpt, int *sign, char *buf, int
double fi, fj;
char *p, *p1;
if (_isnan(arg))
{
snprintf(buf, ndigits, "1.#QNAN");
*decpt = 0;
*sign = 0;
return buf;
}
if (!_finite(arg))
{
snprintf(buf, ndigits, "1.#INF");
*decpt = 0;
*sign = 0;
return buf;
}
if (ndigits >= CVTBUFSIZE - 1) ndigits = CVTBUFSIZE - 2;
r2 = 0;
*sign = 0;