Skip to content

Commit d8720f3

Browse files
committed
std: format contents of sentinel terminated many pointers
1 parent c284b99 commit d8720f3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/std/fmt.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ pub fn formatType(
429429
else => return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) }),
430430
},
431431
.Many => {
432+
if (ptr_info.sentinel != null) {
433+
const slice = mem.toSliceConst(u8, value);
434+
return formatType(slice, fmt, options, context, Errors, output, max_depth);
435+
}
432436
if (ptr_info.child == u8) {
433437
if (fmt.len > 0 and fmt[0] == 's') {
434438
const len = mem.len(u8, value);

0 commit comments

Comments
 (0)