From 02cb89ce61c58e0d9281a6fd163375399aaed40e Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 21 May 2017 18:48:45 +1000 Subject: src/lobject.js: l_str2int - keep numbers in representable range --- src/lobject.js | 4 ++-- 1 file 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; } } -- cgit v1.2.3-70-g09d2