aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-09-12 13:32:14 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-09-12 20:08:56 -0400
commitcb6201715a7bcae2b278811186afc17a697b25f7 (patch)
tree30db7b0844d0769b87664e83164f734fae1a9627 /src/codegen.zig
parent7e2b6b0f1bc5877f11c50a217dd88c11481bbad4 (diff)
downloadzig-cb6201715a7bcae2b278811186afc17a697b25f7.tar.gz
zig-cb6201715a7bcae2b278811186afc17a697b25f7.zip
InternPool: prevent anon struct UAF bugs with type safety
Instead of using actual slices for InternPool.Key.AnonStructType, this commit changes to use Slice types instead, which store a long-lived index rather than a pointer. This is a follow-up to 7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b.
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index 3a802f4d86..4d1993434a 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -438,7 +438,11 @@ pub fn generateSymbol(
},
.anon_struct_type => |tuple| {
const struct_begin = code.items.len;
- for (tuple.types, tuple.values, 0..) |field_ty, comptime_val, index| {
+ for (
+ tuple.types.get(ip),
+ tuple.values.get(ip),
+ 0..,
+ ) |field_ty, comptime_val, index| {
if (comptime_val != .none) continue;
if (!field_ty.toType().hasRuntimeBits(mod)) continue;