mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[CRT] Fix cvt to not overflow the buffer on NAN/INF
Fixes crash in msvcrt_winetest printf
This commit is contained in:
parent
4a63e19e47
commit
166d83b206
1 changed files with 15 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue