From e3a798740c2d64d0ac0dd4a08ebfec9d5a1c3cf8 Mon Sep 17 00:00:00 2001 From: amelia squires Date: Sat, 27 Sep 2025 04:11:49 -0500 Subject: leaks and memory fixes --- src/lua.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/lua.c') diff --git a/src/lua.c b/src/lua.c index 2623e29..c51a906 100644 --- a/src/lua.c +++ b/src/lua.c @@ -51,7 +51,7 @@ int _stream_read(lua_State* L){ } lua_pushlstring(L, cont->c, cont->len); - free(cont); + str_free(cont); return 1; } @@ -185,6 +185,9 @@ void luaI_deepcopy(lua_State* src, lua_State* dest, enum deep_copy_flags flags){ case LUA_TBOOLEAN: lua_pushboolean(dest, lua_toboolean(src, -1)); break; + case LUA_TNIL: + lua_pushnil(dest); + break; case LUA_TSTRING:; size_t slen; const char* ss = lua_tolstring(src, -1, &slen); @@ -403,6 +406,7 @@ void luaI_copyvars(lua_State* from, lua_State* to){ env_table(from, x != 0); luaI_deepcopy(from, to, SKIP_GC | SKIP_LOCALS); + lua_pop(from, 1); int idx = lua_gettop(to); lua_pushglobaltable(to); int tidx = lua_gettop(to); -- cgit v1.2.3