authorgravatar for tgschultz@gmail.comtgschultz <tgschultz@gmail.com> 2018-08-14 12:56:41-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2018-08-14 12:56:41-05:00
logfa955f0024bc1e63200f6c6e3d22cf88dc6a65a5
tree40121670ba4c0ad573029ed678fda0415d0aaede
parent52471f6221c76f47b0661754511b3559e60fd801
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

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.

1 files changed, 1 insertions(+), 1 deletions(-)

std/fmt/index.zig+1-1
...@@ -179,7 +179,7 @@ pub fn formatType(...@@ -179,7 +179,7 @@ pub fn formatType(
179 },179 },
180 builtin.TypeInfo.Pointer.Size.Many => {180 builtin.TypeInfo.Pointer.Size.Many => {
181 if (ptr_info.child == u8) {181 if (ptr_info.child == u8) {
182 if (fmt[0] == 's') {182 if (fmt.len > 0 and fmt[0] == 's') {
183 const len = std.cstr.len(value);183 const len = std.cstr.len(value);
184 return formatText(value[0..len], fmt, context, Errors, output);184 return formatText(value[0..len], fmt, context, Errors, output);
185 }185 }