From 6212a1e45f14e6f857d7ce5f1cc69ca9080b9282 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 9 May 2017 15:55:58 +1000 Subject: src/lapi.js: Delete unwanted stack items --- src/lapi.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/lapi.js') 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) { -- cgit v1.2.3-54-g00ecf