From e145a883400796f2338f80c102f739fa8589d14a Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 31 May 2026 18:04:27 -0700 Subject: [PATCH] fix another case --- ...me:6342,execs:4701,op:arith8,pos:55,val:+3 | 30 +++++++++++++++++++ test.zig | 1 + yaml.zig | 6 ++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 fuzz/crashes/id:000000,sig:06,src:000000,time:6342,execs:4701,op:arith8,pos:55,val:+3 diff --git a/fuzz/crashes/id:000000,sig:06,src:000000,time:6342,execs:4701,op:arith8,pos:55,val:+3 b/fuzz/crashes/id:000000,sig:06,src:000000,time:6342,execs:4701,op:arith8,pos:55,val:+3 new file mode 100644 index 0000000000000000000000000000000000000000..ed150f28a5a6bfec8d4b5646e6b8199a39e738dd --- /dev/null +++ b/fuzz/crashes/id:000000,sig:06,src:000000,time:6342,execs:4701,op:arith8,pos:55,val:+3 @@ -0,0 +1,30 @@ +id: g982zq6e8wsvnmduerpbf8787hu85brugmngn8wf +name: yaml main: yaml.zig +license: MIT +description: A Yaml parser built on top of libyaml +dependencies: + - src: git https://github.com/yaml/libyaml tag-0.2.5 + id: 8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc + license: MIT + c_include_dirs: + - include + c_source_flags: + - -DYAML_VERSION_MAJOR=0 + - -DYAML_VERSION_MINOR=2 + - -DYAML_VERSION_PATCH=5 + - -DYAML_VERSION_STRING="0.2.5" + - -DYAML_DECLARE_STATIC=1 + c_source_files: + - src/api.c + - src/dumper.c + - src/emitter.c + - src/loader.c + - src/parser.c + - src/reader.c + - src/scanner.c + - src/writer.c + + - src: git https://github.com/nektro/zig-extras + +root_dependencies: + - src: git https://github.com/nektro/zig-expect diff --git a/test.zig b/test.zig index 63a1289ffd77958d39cc9b01fae705e3a5d278e8..6ca54a0ea74334e8194e7f12e30d630bdaffddf4 100644 --- a/test.zig +++ b/test.zig @@ -20,6 +20,7 @@ fn fuzzCase(embedfile_content: []const u8) void { // zig fmt: off test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:2049,execs:911,op:quick,pos:263")); } +test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:6342,execs:4701,op:arith8,pos:55,val:+3")); } // zig fmt: on fn parseTest(comptime basename: [:0]const u8) !void { diff --git a/yaml.zig b/yaml.zig index a71be83a88b319f6595d7784308f45d41a424b6b..746ac3e4120156869986d6888b2c3e234c9bc390 100644 --- a/yaml.zig +++ b/yaml.zig @@ -212,7 +212,7 @@ pub fn parse(alloc: std.mem.Allocator, input: string) !Document { _ = c.yaml_parser_initialize(&parser); defer c.yaml_parser_delete(&parser); - const lines = try split(alloc, input, '\n'); + const lines = try split(alloc, input); defer alloc.free(lines); _ = c.yaml_parser_set_input_string(&parser, input.ptr, input.len); @@ -401,11 +401,11 @@ fn get_event_string(event: Token, p: *const Parser) ![:0]u8 { // // -fn split(alloc: std.mem.Allocator, in: string, delim: u8) ![]string { +fn split(alloc: std.mem.Allocator, in: string) ![]string { var list = std.ArrayList(string).init(alloc); errdefer list.deinit(); - var iter = std.mem.splitScalar(u8, in, delim); + var iter = std.mem.splitAny(u8, in, "\r\n"); while (iter.next()) |str| { try list.append(str); } -- 2.54.0