aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-09-21 21:55:41 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-09-21 21:55:41 -0700
commit747440677dc58394c73235627d9016ee5f7588d8 (patch)
tree1ddc55186d1741fd7a9f9088f63763ae11a8fd67 /src/codegen
parent81b5df347a2b92566dc679fdd4e110812dfe27d0 (diff)
downloadzig-747440677dc58394c73235627d9016ee5f7588d8.tar.gz
zig-747440677dc58394c73235627d9016ee5f7588d8.zip
LLVM: fix UAF when lowering debug info for structs
Gotta call the get() function inside the loop if the loop adds anything to InternPool.
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index c06a5ffd5c..dc2e2f3859 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -2495,17 +2495,16 @@ pub const Object = struct {
}
const struct_type = mod.typeToStruct(ty).?;
- const field_types = struct_type.field_types.get(ip);
var di_fields: std.ArrayListUnmanaged(*llvm.DIType) = .{};
defer di_fields.deinit(gpa);
- try di_fields.ensureUnusedCapacity(gpa, field_types.len);
+ try di_fields.ensureUnusedCapacity(gpa, struct_type.field_types.len);
comptime assert(struct_layout_version == 2);
var it = struct_type.iterateRuntimeOrder(ip);
while (it.next()) |field_index| {
- const field_ty = field_types[field_index].toType();
+ const field_ty = struct_type.field_types.get(ip)[field_index].toType();
if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) continue;
const field_size = field_ty.abiSize(mod);
const field_align = mod.structFieldAlignment(