mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
TypedValue: fix crash when string-like aggregate has undefined element
Closes #6334
This commit is contained in:
parent
23b7d28896
commit
92dfc07489
@ -176,7 +176,9 @@ pub fn print(
|
||||
|
||||
var i: u32 = 0;
|
||||
while (i < max_len) : (i += 1) {
|
||||
buf[i] = std.math.cast(u8, val.fieldValue(ty, i).toUnsignedInt(target)) orelse break :str;
|
||||
const elem = val.fieldValue(ty, i);
|
||||
if (elem.isUndef()) break :str;
|
||||
buf[i] = std.math.cast(u8, elem.toUnsignedInt(target)) orelse break :str;
|
||||
}
|
||||
|
||||
const truncated = if (len > max_string_len) " (truncated)" else "";
|
||||
@ -390,6 +392,7 @@ pub fn print(
|
||||
while (i < max_len) : (i += 1) {
|
||||
var elem_buf: Value.ElemValueBuffer = undefined;
|
||||
const elem_val = payload.ptr.elemValueBuffer(mod, i, &elem_buf);
|
||||
if (elem_val.isUndef()) break :str;
|
||||
buf[i] = std.math.cast(u8, elem_val.toUnsignedInt(target)) orelse break :str;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user