diff options
| author | tgschultz <tgschultz@gmail.com> | 2018-08-14 12:56:41 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-14 12:56:41 -0500 |
| commit | fa955f0024bc1e63200f6c6e3d22cf88dc6a65a5 (patch) | |
| tree | 40121670ba4c0ad573029ed678fda0415d0aaede /std | |
| parent | 52471f6221c76f47b0661754511b3559e60fd801 (diff) | |
| download | zig-fa955f0024bc1e63200f6c6e3d22cf88dc6a65a5.tar.gz zig-fa955f0024bc1e63200f6c6e3d22cf88dc6a65a5.zip | |
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.
Diffstat (limited to 'std')
| -rw-r--r-- | std/fmt/index.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/std/fmt/index.zig b/std/fmt/index.zig index f4f9efee37..a9ae979323 100644 --- a/std/fmt/index.zig +++ b/std/fmt/index.zig @@ -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); } |
