diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-24 15:25:43 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-24 15:25:43 +1000 |
commit | c25b209c8b7744916111dc0c4fd0b2a1ddc72352 (patch) | |
tree | 6efac3fb4bde3c7517c1865250f69729c3117c70 | |
parent | 39f0e15c8e834a439aaef35c50e76df0713433c4 (diff) | |
download | fengari-c25b209c8b7744916111dc0c4fd0b2a1ddc72352.tar.gz fengari-c25b209c8b7744916111dc0c4fd0b2a1ddc72352.tar.bz2 fengari-c25b209c8b7744916111dc0c4fd0b2a1ddc72352.zip |
src/lvm.js: loops with integers should overflow
-rw-r--r-- | src/lvm.js | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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); |