diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-06-02 05:07:07 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:47:59 -0700 |
| commit | 7a59cd286345470412b4880ca576553c7d5827eb (patch) | |
| tree | 9418bf6740c876b34e1da7bac294ebbf8faa5b5d /src/Sema.zig | |
| parent | da24ea7f36d056cb49e8e91064f06cb724e46f67 (diff) | |
| download | zig-7a59cd286345470412b4880ca576553c7d5827eb.tar.gz zig-7a59cd286345470412b4880ca576553c7d5827eb.zip | |
Sema: hack around UAF
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 0ffd79bec3..8c657b3f52 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -26792,11 +26792,12 @@ fn coerceValueInMemory( else => unreachable, }; if (src_ty_child != dst_ty_child) break :direct; + // TODO: write something like getCoercedInts to avoid needing to dupe return (try mod.intern(.{ .aggregate = .{ .ty = dst_ty.toIntern(), .storage = switch (aggregate.storage) { - .bytes => |bytes| .{ .bytes = bytes[0..dest_len] }, - .elems => |elems| .{ .elems = elems[0..dest_len] }, + .bytes => |bytes| .{ .bytes = try sema.arena.dupe(u8, bytes[0..dest_len]) }, + .elems => |elems| .{ .elems = try sema.arena.dupe(InternPool.Index, elems[0..dest_len]) }, .repeated_elem => |elem| .{ .repeated_elem = elem }, }, } })).toValue(); |
