aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2022-03-17 21:20:00 +0100
committerAndrew Kelley <andrew@ziglang.org>2022-03-17 18:20:03 -0700
commit79679be50ddfab04d34cb3dc412d4e5088de2126 (patch)
tree1adf8cb526b44064f524d4bcf425a4446d381a6d
parent9dc9219b2feb5971ca5e86e0d0880233f28cf18c (diff)
downloadzig-79679be50ddfab04d34cb3dc412d4e5088de2126.tar.gz
zig-79679be50ddfab04d34cb3dc412d4e5088de2126.zip
sema: Fix memory leak
When a generic call evaluates to a generic type, the call will be re-generated. However, the old function was not freed before being re-generated, causing a memory leak. So rather than only returning an error, we first free the old value.
-rw-r--r--src/Sema.zig1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 8fda67b652..fd067d6460 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -5068,6 +5068,7 @@ fn instantiateGenericCall(
};
const new_func_val = child_sema.resolveConstValue(&child_block, .unneeded, new_func_inst) catch unreachable;
const new_func = new_func_val.castTag(.function).?.data;
+ errdefer new_func.deinit(gpa);
assert(new_func == new_module_func);
arg_i = 0;