authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-07 17:29:11-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-08 00:06:17-04:00
loga9b37ac63724a79805f00b4e6966ebb8329151a2
tree886d9da532f7fbf02001858ed8c9cc4cad9dc1d8
parentd68f39b5412e0aeb59d71c9f676221212261dc8c

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.

1 files changed, 2 insertions(+), 1 deletions(-)

src/codegen/c.zig+2-1
...@@ -592,7 +592,8 @@ pub const DeclGen = struct {...@@ -592,7 +592,8 @@ pub const DeclGen = struct {
592592
593 // Indicate that the anon decl should be rendered to the output so that593 // Indicate that the anon decl should be rendered to the output so that
594 // our reference above is not undefined.594 // our reference above is not undefined.
595 _ = try dg.anon_decl_deps.getOrPut(dg.gpa, decl_val);595 const gop = try dg.anon_decl_deps.getOrPut(dg.gpa, decl_val);
596 if (!gop.found_existing) gop.value_ptr.* = .{};
596 }597 }
597598
598 fn renderDeclValue(599 fn renderDeclValue(