From a576b295a7be0598f1173ba5ab2f586bc9a23aed Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 7 Oct 2023 17:29:11 -0400 Subject: [PATCH] cbe: fix crash on error This hashmap value used to be assigned much later during `flushModule`, which never happens if an error is returned by the backend, and attempting to the undefined values would cause a crash. --- src/codegen/c.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 3278ed89b095..94598985c060 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -592,7 +592,8 @@ pub const DeclGen = struct { // Indicate that the anon decl should be rendered to the output so that // our reference above is not undefined. - _ = try dg.anon_decl_deps.getOrPut(dg.gpa, decl_val); + const gop = try dg.anon_decl_deps.getOrPut(dg.gpa, decl_val); + if (!gop.found_existing) gop.value_ptr.* = .{}; } fn renderDeclValue(