authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-08 01:46:07 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-08 01:55:04 -07:00
log74a41951e6b4957415868983ed24338256176457
tree499bdaefcd4b597371ca306d21779baf985d4bfd
parentd7457589a5d85d3005e6e2dfc0748bb704e82bbb
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

handle anchor events and fix another crash


3 files changed, 41 insertions(+), 0 deletions(-)

fuzz/crashes/id:000000,sig:06,src:000000,time:16058,execs:7921,op:arith8,pos:522,val:+10 created+31
...@@ -0,0 +1,31 @@
1id: g982zq6e8wsvnmduerpbf8787hu85brugmngn8wf
2name: yaml
3main: yaml.zig
4license: MIT
5description: A Yaml parser built on top of libyaml
6dependencies:
7 - src: git https://github.com/yaml/libyaml tag-0.2.5
8 id: 8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc
9 license: MIT
10 c_include_dirs:
11 - include
12 c_source_flags:
13 - -DYAML_VERSION_MAJOR=0
14 - -DYAML_VERSION_MINOR=2
15 - -DYAML_VERSION_PATCH=5
16 - -DYAML_VERSION_STRING="0.2.5"
17 - -DYAML_DECLARE_STATIC=1
18 c_source_files:
19 *- src/api.c
20 - src/dumper.c
21 - src/emitter.c
22 - src/loader.c
23 - src/parser.c
24 - src/reader.c
25 - src/scanner.c
26 - src/writer.c
27
28 - src: git https://github.com/nektro/zig-extras
29
30root_dependencies:
31 - src: git https://github.com/nektro/zig-expect
test.zig+1
...@@ -24,6 +24,7 @@ test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:6342...@@ -24,6 +24,7 @@ test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:6342
24test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:1310,execs:717,op:quick,pos:97")); }24test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:1310,execs:717,op:quick,pos:97")); }
25test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:1399,execs:755,op:quick,pos:149")); }25test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:1399,execs:755,op:quick,pos:149")); }
26test { fuzzCase(@embedFile("./fuzz/crashes/id:000002,sig:06,src:000000,time:12249,execs:9637,op:int8,pos:0,val:+32")); }26test { fuzzCase(@embedFile("./fuzz/crashes/id:000002,sig:06,src:000000,time:12249,execs:9637,op:int8,pos:0,val:+32")); }
27test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:16058,execs:7921,op:arith8,pos:522,val:+10")); }
27// zig fmt: on28// zig fmt: on
2829
29fn parseTest(comptime basename: [:0]const u8) !void {30fn parseTest(comptime basename: [:0]const u8) !void {
yaml.zig+9
...@@ -39,6 +39,7 @@ pub const Item = union(enum) {...@@ -39,6 +39,7 @@ pub const Item = union(enum) {
39 sequence: Sequence,39 sequence: Sequence,
40 string: [:0]const u8,40 string: [:0]const u8,
41 stream: Stream,41 stream: Stream,
42 anchor: [:0]const u8,
4243
43 pub fn deinit(self: *const Item, alloc: std.mem.Allocator) void {44 pub fn deinit(self: *const Item, alloc: std.mem.Allocator) void {
44 switch (self.*) {45 switch (self.*) {
...@@ -51,6 +52,7 @@ pub const Item = union(enum) {...@@ -51,6 +52,7 @@ pub const Item = union(enum) {
51 },52 },
52 .string => |s| alloc.free(s),53 .string => |s| alloc.free(s),
53 .stream => |s| s.deinit(alloc),54 .stream => |s| s.deinit(alloc),
55 .anchor => {},
54 }56 }
55 }57 }
5658
...@@ -76,6 +78,9 @@ pub const Item = union(enum) {...@@ -76,6 +78,9 @@ pub const Item = union(enum) {
76 .string => {78 .string => {
77 try writer.print("{s}", .{self.string});79 try writer.print("{s}", .{self.string});
78 },80 },
81 .anchor => {
82 //
83 },
79 }84 }
80 try writer.writeAll("}");85 try writer.writeAll("}");
81 }86 }
...@@ -97,6 +102,7 @@ pub const Value = union(enum) {...@@ -97,6 +102,7 @@ pub const Value = union(enum) {
97 string: [:0]const u8,102 string: [:0]const u8,
98 mapping: Mapping,103 mapping: Mapping,
99 sequence: Sequence,104 sequence: Sequence,
105 anchor: [:0]const u8,
100106
101 pub fn deinit(self: *const Value, alloc: std.mem.Allocator) void {107 pub fn deinit(self: *const Value, alloc: std.mem.Allocator) void {
102 switch (self.*) {108 switch (self.*) {
...@@ -108,6 +114,7 @@ pub const Value = union(enum) {...@@ -108,6 +114,7 @@ pub const Value = union(enum) {
108 for (s) |*item| item.deinit(alloc);114 for (s) |*item| item.deinit(alloc);
109 alloc.free(s);115 alloc.free(s);
110 },116 },
117 .anchor => {},
111 }118 }
112 }119 }
113120
...@@ -268,6 +275,7 @@ fn parse_item(p: *Parser, start: ?Token) Error!Item {...@@ -268,6 +275,7 @@ fn parse_item(p: *Parser, start: ?Token) Error!Item {
268 c.YAML_MAPPING_START_EVENT => Item{ .mapping = try parse_mapping(p) },275 c.YAML_MAPPING_START_EVENT => Item{ .mapping = try parse_mapping(p) },
269 c.YAML_SEQUENCE_START_EVENT => Item{ .sequence = try parse_sequence(p) },276 c.YAML_SEQUENCE_START_EVENT => Item{ .sequence = try parse_sequence(p) },
270 c.YAML_SCALAR_EVENT => Item{ .string = try get_event_string(tok, p) },277 c.YAML_SCALAR_EVENT => Item{ .string = try get_event_string(tok, p) },
278 c.YAML_ALIAS_EVENT => .{ .anchor = std.mem.sliceTo(tok.data.alias.anchor, 0) },
271 else => unreachable,279 else => unreachable,
272 };280 };
273}281}
...@@ -344,6 +352,7 @@ fn parse_value(p: *Parser) Error!Value {...@@ -344,6 +352,7 @@ fn parse_value(p: *Parser) Error!Value {
344 .mapping => |x| Value{ .mapping = x },352 .mapping => |x| Value{ .mapping = x },
345 .sequence => |x| Value{ .sequence = x },353 .sequence => |x| Value{ .sequence = x },
346 .string => |x| Value{ .string = x },354 .string => |x| Value{ .string = x },
355 .anchor => |x| Value{ .anchor = x },
347 else => unreachable,356 else => unreachable,
348 };357 };
349}358}