runtime: fix memory leaks

This commit is contained in:
2026-05-30 19:52:36 +01:00
parent 26b368a512
commit 96bf76aabc
9 changed files with 75 additions and 19 deletions
+13 -2
View File
@@ -37,7 +37,14 @@ void runtime_pop_scope(struct bshell_runtime *rt)
struct bshell_runtime_scope *scope
= fx_unbox(struct bshell_runtime_scope, entry, s_entry);
/* TODO */
if (scope->s_block) {
bshell_scriptblock_unref(scope->s_block);
}
fx_value_unset_array(scope->s_stack.items, scope->s_stack.count);
var_map_cleanup(&scope->s_vars);
fx_vector_destroy(scope->s_stack, NULL);
fx_hashtable_unref(scope->s_functions);
free(scope);
}
@@ -79,7 +86,11 @@ void bshell_runtime_scope_set_block(
struct bshell_runtime_scope *scope,
bshell_scriptblock *block)
{
scope->s_block = block;
if (scope->s_block) {
bshell_scriptblock_unref(scope->s_block);
}
scope->s_block = bshell_scriptblock_ref(block);
scope->s_ip = 0;
bshell_scriptblock_get_text(block, &scope->s_instr, &scope->s_nr_instr);
bshell_scriptblock_get_pool(block, &scope->s_pool, &scope->s_nr_pool);