summaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-02-04 11:05:50 -0800
committerdaurnimator <quae@daurnimator.com>2018-02-04 11:05:50 -0800
commite4acea84c0807c4a5d601a89d0ebba73f51eb05f (patch)
treeba14717394dc9e032d66ffecd11fbbf43f051c28 /src/lobject.js
parentc566658e3ba9279aa20dd63fd7718357e857133b (diff)
parentdc9eceb56d1d0d37c31887bffc48816bf53ddf3c (diff)
downloadfengari-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.js7
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 {