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 7ef1eb1c27.
This commit is contained in:
Andrew Kelley
2023-09-12 13:32:14 -07:00
parent 7e2b6b0f1b
commit cb6201715a
10 changed files with 248 additions and 178 deletions

View File

@@ -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;