mirror of
https://github.com/reactos/reactos.git
synced 2026-06-08 17:02:56 +08:00
[CRT] Fix cvt to not overflow the buffer on NAN/INF
Fixes crash in msvcrt_winetest printf
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user