浏览代码

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 年之前
父节点
当前提交
d24cda64d1
共有 1 个文件被更改,包括 3 次插入1 次删除
  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();
                 }