From e2b49957cd8154aea3fa2b5230a822ae9300d547 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 2 Sep 2026 13:09:45 -0700 Subject: [PATCH] avoid panic if rest of line is all whitespace --- src/srf.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/srf.zig b/src/srf.zig index be63392..9e42fa7 100644 --- a/src/srf.zig +++ b/src/srf.zig @@ -331,7 +331,8 @@ pub const Value = union(enum) { // be a comma. If in long mode, we could have whitespace + comment var buf: [256]u8 = undefined; if (state.field_delimiter == '\n') { - if (std.mem.trimStart(u8, past_val, std.ascii.whitespace[0..])[0] != '#') { + const rest = std.mem.trimStart(u8, past_val, std.ascii.whitespace[0..]); + if (rest.len > 0 and rest[0] != '#') { const msg = std.fmt.bufPrint( &buf, "line has {} additional bytes after field value. Perhaps length should be restated as {}?",