Skip to content

Commit

Permalink
fix: proxy-base table stack leak
Browse files Browse the repository at this point in the history
  • Loading branch information
X3ZvaWQ committed Feb 15, 2024
1 parent 6ee5049 commit 724ec92
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wasmoon-lua5.1",
"version": "1.18.5",
"version": "1.18.6",
"description": "A real lua 5.1 VM with JS bindings made with webassembly",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class LuaTable {
this.thread.pushValue(key);
this.thread.luaApi.lua_gettable(this.thread.address, -2);
const result = this.thread.getValue(-1);
this.thread.pop();
this.thread.pop(2);
return result;
}

Expand Down
18 changes: 6 additions & 12 deletions test/debug.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ import { Lua } from '../dist/index.js';

const lua = await Lua.create();

function test() {
return 1234;
}
lua.ctx.a = { name: 'a' };
lua.ctx.a.b = { name: 'b' };
lua.ctx.a.b.c = { name: 'c' };
lua.ctx.a.b.c.d = { name: 'd' };

for (const index of Array.from({ length: 1 }, (_, i) => i + 1)) {
console.log(index);
lua.ctx.test = test;
for (const i of Array.from({ length: 50 }, (_, i) => i + 1)) {
await lua.doString('test()');
await lua.doString(`print(test.x)`);
await lua.doString(`test.x = ${i}`);
}
}
lua.global.dumpStack();
console.log(lua.global.getValue(-1).$detach());

0 comments on commit 724ec92

Please sign in to comment.