diff options
| author | apocelipes <[email protected]> | 2026-07-31 15:31:06 +0800 |
|---|---|---|
| committer | apocelipes <[email protected]> | 2026-07-31 15:31:06 +0800 |
| commit | b3f07139d26efe81036f814ab4be4b83be17c53d (patch) | |
| tree | 2c695295dd4f0a357c3421ff183ee2d205fb3fa1 | |
| parent | a928217681c4c5dc60b80a230182e5254bc30c8d (diff) | |
fix: fix engine resource leaks
Release the argument block returned by CommandLineToArgvW after copying its values into Lua.
Destroy embedded output streams after initialization even when opening the backing file fails.
| -rw-r--r-- | core/src/xmake/engine.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index b93b29bb0..b37817cc9 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -814,6 +814,10 @@ static tb_bool_t xm_engine_save_arguments(xm_engine_t *engine, tb_int_t argc, tb lua_rawseti(engine->lua, -2, (int)lua_objlen(engine->lua, -2) + 1); } +#if defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX) + LocalFree(argvw); +#endif + // _ARGV = table_new lua_setglobal(engine->lua, "_ARGV"); return tb_true; @@ -1445,8 +1449,8 @@ static tb_bool_t xm_engine_extract_programfiles_impl(xm_engine_t *engine, if (tb_stream_open(stream)) { tb_stream_bwrit(stream, p, n); - tb_stream_exit(stream); } + tb_stream_exit(stream); p += n; } |
