summaryrefslogtreecommitdiff
path: root/src/lvm.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-24 15:25:43 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-24 15:25:43 +1000
commitc25b209c8b7744916111dc0c4fd0b2a1ddc72352 (patch)
tree6efac3fb4bde3c7517c1865250f69729c3117c70 /src/lvm.js
parent39f0e15c8e834a439aaef35c50e76df0713433c4 (diff)
downloadfengari-c25b209c8b7744916111dc0c4fd0b2a1ddc72352.tar.gz
fengari-c25b209c8b7744916111dc0c4fd0b2a1ddc72352.tar.bz2
fengari-c25b209c8b7744916111dc0c4fd0b2a1ddc72352.zip
src/lvm.js: loops with integers should overflow
Diffstat (limited to 'src/lvm.js')
-rw-r--r--src/lvm.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lvm.js b/src/lvm.js
index 0081376..cd197ab 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -516,7 +516,7 @@ const luaV_execute = function(L) {
case OCi.OP_FORLOOP: {
if (L.stack[ra].ttisinteger()) { /* integer loop? */
let step = L.stack[ra + 2].value;
- let idx = L.stack[ra].value + step;
+ let idx = (L.stack[ra].value + step)|0;
let limit = L.stack[ra + 1].value;
if (0 < step ? idx <= limit : limit <= idx) {
@@ -547,7 +547,7 @@ const luaV_execute = function(L) {
if (init.ttisinteger() && pstep.ttisinteger() && forlim.casted) { /* all values are integer */
let initv = forlim.stopnow ? 0 : init.value;
plimit.value = forlim.ilimit;
- init.value = initv - pstep.value;
+ init.value = (initv - pstep.value)|0;
} else { /* try making all values floats */
let ninit = tonumber(init);
let nlimit = tonumber(plimit);