Check for exponent overflow in float parser
Even for a double precision float, the largest valid exponent is 308, so clamp exponents to 500 when parsing to avoid overflow of the parsed exponent value if the exponent is too big.
This commit is contained in:
parent
0015dc9345
commit
d24cda64d1
1 changed files with 3 additions and 1 deletions
|
|
@ -220,7 +220,9 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
|
||||||
}
|
}
|
||||||
if (ch >= '0' && ch <= '9') {
|
if (ch >= '0' && ch <= '9') {
|
||||||
while (ch >= '0' && ch <= '9') {
|
while (ch >= '0' && ch <= '9') {
|
||||||
|
if (exponent < 500) {
|
||||||
exponent = exponent * 10 + (ch - '0');
|
exponent = exponent * 10 + (ch - '0');
|
||||||
|
}
|
||||||
saveName(ch);
|
saveName(ch);
|
||||||
ch = getChar();
|
ch = getChar();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue