mirror of
https://github.com/ziglang/zig.git
synced 2024-11-16 00:57:04 +00:00
fixed handling of [*]u8 when no format specifier is set
If fmt was called on with a [*]u8 or [*]const u8 argument, but the fmt string did not specify 's' to treat it as a string, it produced a compile error due to accessing index 1 of a 0 length slice.
This commit is contained in:
parent
52471f6221
commit
fa955f0024
@ -179,7 +179,7 @@ pub fn formatType(
|
||||
},
|
||||
builtin.TypeInfo.Pointer.Size.Many => {
|
||||
if (ptr_info.child == u8) {
|
||||
if (fmt[0] == 's') {
|
||||
if (fmt.len > 0 and fmt[0] == 's') {
|
||||
const len = std.cstr.len(value);
|
||||
return formatText(value[0..len], fmt, context, Errors, output);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user