summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-09 15:55:58 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-09 15:55:58 +1000
commit6212a1e45f14e6f857d7ce5f1cc69ca9080b9282 (patch)
tree2253144049a32c8a9a3850e0da22f9d918f7de77 /src
parentac24f3f4368728c7e451ec7c1d2a77b3221940c0 (diff)
downloadfengari-6212a1e45f14e6f857d7ce5f1cc69ca9080b9282.tar.gz
fengari-6212a1e45f14e6f857d7ce5f1cc69ca9080b9282.tar.bz2
fengari-6212a1e45f14e6f857d7ce5f1cc69ca9080b9282.zip
src/lapi.js: Delete unwanted stack items
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lapi.js b/src/lapi.js
index e847cec..e035aca 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -133,7 +133,9 @@ const lua_settop = function(L, idx) {
L.top = func + 1 + idx;
} else {
assert(-(idx + 1) <= L.top - (func + 1), "invalid new top");
- L.top += idx + 1; /* 'subtract' index (index is negative) */
+ let newtop = L.top + idx + 1; /* 'subtract' index (index is negative) */
+ while (L.top > newtop)
+ delete L.stack[--L.top];
}
};
@@ -339,7 +341,8 @@ const auxsetstr = function(L, t, k) {
L.stack[L.top++] = str;
lvm.settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]);
/* pop value and key */
- L.top -= 2;
+ delete L.stack[--L.top];
+ delete L.stack[--L.top];
};
const lua_setglobal = function(L, name) {