mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 22:04:21 +00:00
sema: fix memory corruption caused by resolveStructLayout
This commit is contained in:
parent
7e9a760482
commit
c7067ef6e8
2 changed files with 4 additions and 2 deletions
|
|
@ -30369,7 +30369,9 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (struct_obj.layout == .Auto and sema.mod.backendSupportsFeature(.field_reordering)) {
|
if (struct_obj.layout == .Auto and sema.mod.backendSupportsFeature(.field_reordering)) {
|
||||||
const optimized_order = blk: {
|
const optimized_order = if (struct_obj.owner_decl == sema.owner_decl_index)
|
||||||
|
try sema.perm_arena.alloc(u32, struct_obj.fields.count())
|
||||||
|
else blk: {
|
||||||
const decl = sema.mod.declPtr(struct_obj.owner_decl);
|
const decl = sema.mod.declPtr(struct_obj.owner_decl);
|
||||||
var decl_arena = decl.value_arena.?.promote(sema.mod.gpa);
|
var decl_arena = decl.value_arena.?.promote(sema.mod.gpa);
|
||||||
defer decl.value_arena.?.* = decl_arena.state;
|
defer decl.value_arena.?.* = decl_arena.state;
|
||||||
|
|
|
||||||
|
|
@ -1060,7 +1060,7 @@ pub fn getDeclVAddr(
|
||||||
.offset = reloc_info.offset,
|
.offset = reloc_info.offset,
|
||||||
.addend = reloc_info.addend,
|
.addend = reloc_info.addend,
|
||||||
});
|
});
|
||||||
return undefined;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getDeclBlock(self: *const Plan9, index: DeclBlock.Index) DeclBlock {
|
pub fn getDeclBlock(self: *const Plan9, index: DeclBlock.Index) DeclBlock {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue