From a7833b84773d27a425ba3048b7c4e50a78ccf2eb Mon Sep 17 00:00:00 2001 From: Vic Nightfall Date: Fri, 9 Feb 2024 21:20:52 +0100 Subject: [PATCH] Fix some memory leaks --- src/compiler.pr | 9 ++++++++- std/std.pr | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler.pr b/src/compiler.pr index 756c21d..c521786 100644 --- a/src/compiler.pr +++ b/src/compiler.pr @@ -5453,6 +5453,7 @@ def walk_For_generator(node: &parser::Node, state: &State) { last_node = n } let last_loc = make_location(last_node, state) + insert_destructor(locv, loc, state) insert_destructors(node.inner_scope, last_loc, state) pop_scope(state) @@ -6942,7 +6943,7 @@ def create_free_context(function: &Function, state: &State) { let label_ = state.make_label() push_label(label_, state) switch_values.push([ - value = make_int_value(i + 1), + value = make_int_value(i), label_ = label_ ] !SwitchValue) @@ -7388,6 +7389,12 @@ export def create_function( generate_defer_types_pre(state) if function.has_yield { + // Create new snapshot for arguments + let new_snapshot = map::make(int) + new_snapshot.put_all(function.current_snapshot) + function.current_snapshot = new_snapshot + function.snapshots.push(new_snapshot) + // Get is_at_end pointer let is_at_end_gep = make_insn(InsnKind::GETELEMENTPTR) is_at_end_gep.value.gep = [ diff --git a/std/std.pr b/std/std.pr index afe8270..0a19da0 100644 --- a/std/std.pr +++ b/std/std.pr @@ -28,7 +28,7 @@ from strings export * ref_roots = zero_allocate(type &map::Map(uint64, Root)) @ref_roots = map::make(uint64, Root) } - (@ref_roots)(ref.value !uint64) = [ ref, make_string(file), line ] !Root + (@ref_roots)(ref.value !uint64) = [ ref = ref, file = make_string(file), line = line ] !Root lock = l }