authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-26 02:29:07+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-26 02:29:07+02:00
logf95ec229f8478eedbb59700cbd223367ebd89a86
tree15a9c47f38b5671e29d568c6f8de895b06a9e7f3
parent914993123c91534e4fa1d32c93bc43341cb24a8c

stage2: fix use-after-free in analyzeBlockBody


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

src/Sema.zig+2-1
...@@ -3035,10 +3035,11 @@ fn analyzeBlockBody(...@@ -3035,10 +3035,11 @@ fn analyzeBlockBody(
3035 // to emit a jump instruction to after the block when it encounters the break.3035 // to emit a jump instruction to after the block when it encounters the break.
3036 try parent_block.instructions.append(gpa, merges.block_inst);3036 try parent_block.instructions.append(gpa, merges.block_inst);
3037 const resolved_ty = try sema.resolvePeerTypes(parent_block, src, merges.results.items, .none);3037 const resolved_ty = try sema.resolvePeerTypes(parent_block, src, merges.results.items, .none);
3038 const ty_inst = try sema.addType(resolved_ty);
3038 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +3039 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +
3039 child_block.instructions.items.len);3040 child_block.instructions.items.len);
3040 sema.air_instructions.items(.data)[merges.block_inst] = .{ .ty_pl = .{3041 sema.air_instructions.items(.data)[merges.block_inst] = .{ .ty_pl = .{
3041 .ty = try sema.addType(resolved_ty),3042 .ty = ty_inst,
3042 .payload = sema.addExtraAssumeCapacity(Air.Block{3043 .payload = sema.addExtraAssumeCapacity(Air.Block{
3043 .body_len = @intCast(u32, child_block.instructions.items.len),3044 .body_len = @intCast(u32, child_block.instructions.items.len),
3044 }),3045 }),