Browse Source

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.
Arcady Goldmints-Orlov 1 year ago
parent
commit
d24cda64d1
1 changed files with 3 additions and 1 deletions
  1. 3 1
      glslang/MachineIndependent/preprocessor/PpScanner.cpp

+ 3 - 1
glslang/MachineIndependent/preprocessor/PpScanner.cpp

@@ -220,7 +220,9 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
             }
             if (ch >= '0' && ch <= '9') {
                 while (ch >= '0' && ch <= '9') {
-                    exponent = exponent * 10 + (ch - '0');
+                    if (exponent < 500) {
+                        exponent = exponent * 10 + (ch - '0');
+                    }
                     saveName(ch);
                     ch = getChar();
                 }