aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-04-16 22:38:54 +0100
committermlugg <mlugg@mlugg.co.uk>2024-04-17 13:41:26 +0100
commit3c45a945285dff00d0eb8160342560bcb7d24cc5 (patch)
tree14fe52e9fae68ad8853146e912422dff70e0c73e
parent03ad862197d27fb079d16cabdf2026da23aa2653 (diff)
downloadzig-3c45a945285dff00d0eb8160342560bcb7d24cc5.tar.gz
zig-3c45a945285dff00d0eb8160342560bcb7d24cc5.zip
Value: fix out-of-bounds slice access writing zero-bit undef value
I have no idea why this wasn't being hit on master before.
-rw-r--r--src/Value.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Value.zig b/src/Value.zig
index 20674ff7d9..2e1a873867 100644
--- a/src/Value.zig
+++ b/src/Value.zig
@@ -469,7 +469,9 @@ pub fn writeToPackedMemory(
const endian = target.cpu.arch.endian();
if (val.isUndef(mod)) {
const bit_size: usize = @intCast(ty.bitSize(mod));
- std.mem.writeVarPackedInt(buffer, bit_offset, bit_size, @as(u1, 0), endian);
+ if (bit_size != 0) {
+ std.mem.writeVarPackedInt(buffer, bit_offset, bit_size, @as(u1, 0), endian);
+ }
return;
}
switch (ty.zigTypeTag(mod)) {