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:
Arcady Goldmints-Orlov 2024-03-29 20:09:37 -04:00 committed by arcady-lunarg
parent 0015dc9345
commit d24cda64d1

View file

@ -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') {
exponent = exponent * 10 + (ch - '0'); if (exponent < 500) {
exponent = exponent * 10 + (ch - '0');
}
saveName(ch); saveName(ch);
ch = getChar(); ch = getChar();
} }