diff options
author | daurnimator <quae@daurnimator.com> | 2018-02-04 11:05:50 -0800 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-02-04 11:05:50 -0800 |
commit | e4acea84c0807c4a5d601a89d0ebba73f51eb05f (patch) | |
tree | ba14717394dc9e032d66ffecd11fbbf43f051c28 /src/lobject.js | |
parent | c566658e3ba9279aa20dd63fd7718357e857133b (diff) | |
parent | dc9eceb56d1d0d37c31887bffc48816bf53ddf3c (diff) | |
download | fengari-e4acea84c0807c4a5d601a89d0ebba73f51eb05f.tar.gz fengari-e4acea84c0807c4a5d601a89d0ebba73f51eb05f.tar.bz2 fengari-e4acea84c0807c4a5d601a89d0ebba73f51eb05f.zip |
Merge remote-tracking branch 'daurnimator/optimise-ljstype'
Diffstat (limited to 'src/lobject.js')
-rw-r--r-- | src/lobject.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lobject.js b/src/lobject.js index 5405b34..4b3d0aa 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -547,13 +547,12 @@ const l_str2int = function(s) { else if (s[i] === 43 /* ('+').charCodeAt(0) */) i++; if (s[i] === 48 /* ('0').charCodeAt(0) */ && (s[i+1] === 120 /* ('x').charCodeAt(0) */ || s[i+1] === 88 /* ('X').charCodeAt(0) */)) { /* hex? */ i += 2; /* skip '0x' */ - - for (; lisxdigit(s[i]); i++) { + for (; i < s.length && lisxdigit(s[i]); i++) { a = (a * 16 + luaO_hexavalue(s[i]))|0; empty = false; } } else { /* decimal */ - for (; lisdigit(s[i]); i++) { + for (; i < s.length && lisdigit(s[i]); i++) { let d = s[i] - 48 /* ('0').charCodeAt(0) */; if (a >= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */ return null; /* do not accept it (as integer) */ @@ -561,7 +560,7 @@ const l_str2int = function(s) { empty = false; } } - while (lisspace(s[i])) i++; /* skip trailing spaces */ + while (i < s.length && lisspace(s[i])) i++; /* skip trailing spaces */ if (empty || (i !== s.length && s[i] !== 0)) return null; /* something wrong in the numeral */ else { return { |