Skip to content

Commit

Permalink
cbe: fix crash on error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jacobly0 committed Oct 7, 2023
1 parent d68f39b commit a576b29
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/codegen/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a576b29

Please sign in to comment.