diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-21 18:48:45 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-21 18:48:45 +1000 |
commit | 02cb89ce61c58e0d9281a6fd163375399aaed40e (patch) | |
tree | cc06d5572666015038ab31b80e91528eaee9cdc0 /src/lobject.js | |
parent | de410e79749c1b4fb4d70f318226b9574d62db1d (diff) | |
download | fengari-02cb89ce61c58e0d9281a6fd163375399aaed40e.tar.gz fengari-02cb89ce61c58e0d9281a6fd163375399aaed40e.tar.bz2 fengari-02cb89ce61c58e0d9281a6fd163375399aaed40e.zip |
src/lobject.js: l_str2int - keep numbers in representable range
Diffstat (limited to 'src/lobject.js')
-rw-r--r-- | src/lobject.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lobject.js b/src/lobject.js index 05b1fad..d6ced0b 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -386,7 +386,7 @@ const l_str2int = function(s) { s = s.slice(2); /* skip '0x' */ for (; ljstype.lisxdigit(s[0]); s = s.slice(1)) { - a = a * 16 + luaO_hexavalue(s[0]); + a = (a * 16 + luaO_hexavalue(s[0]))|0; empty = false; } } else { /* decimal */ @@ -394,7 +394,7 @@ const l_str2int = function(s) { let d = s[0] - char['0']; if (a >= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */ return null; /* do not accept it (as integer) */ - a = a * 10 + d; + a = (a * 10 + d)|0; empty = false; } } |