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
2424test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:1310,execs:717,op:quick,pos:97")); }
2525test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:1399,execs:755,op:quick,pos:149")); }
2626test { 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")); }
2728// zig fmt: on
2829
2930fn parseTest(comptime basename: [:0]const u8) !void {
yaml.zig+9
......@@ -39,6 +39,7 @@ pub const Item = union(enum) {
3939 sequence: Sequence,
4040 string: [:0]const u8,
4141 stream: Stream,
42 anchor: [:0]const u8,
4243
4344 pub fn deinit(self: *const Item, alloc: std.mem.Allocator) void {
4445 switch (self.*) {
......@@ -51,6 +52,7 @@ pub const Item = union(enum) {
5152 },
5253 .string => |s| alloc.free(s),
5354 .stream => |s| s.deinit(alloc),
55 .anchor => {},
5456 }
5557 }
5658
......@@ -76,6 +78,9 @@ pub const Item = union(enum) {
7678 .string => {
7779 try writer.print("{s}", .{self.string});
7880 },
81 .anchor => {
82 //
83 },
7984 }
8085 try writer.writeAll("}");
8186 }
......@@ -97,6 +102,7 @@ pub const Value = union(enum) {
97102 string: [:0]const u8,
98103 mapping: Mapping,
99104 sequence: Sequence,
105 anchor: [:0]const u8,
100106
101107 pub fn deinit(self: *const Value, alloc: std.mem.Allocator) void {
102108 switch (self.*) {
......@@ -108,6 +114,7 @@ pub const Value = union(enum) {
108114 for (s) |*item| item.deinit(alloc);
109115 alloc.free(s);
110116 },
117 .anchor => {},
111118 }
112119 }
113120
......@@ -268,6 +275,7 @@ fn parse_item(p: *Parser, start: ?Token) Error!Item {
268275 c.YAML_MAPPING_START_EVENT => Item{ .mapping = try parse_mapping(p) },
269276 c.YAML_SEQUENCE_START_EVENT => Item{ .sequence = try parse_sequence(p) },
270277 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) },
271279 else => unreachable,
272280 };
273281}
......@@ -344,6 +352,7 @@ fn parse_value(p: *Parser) Error!Value {
344352 .mapping => |x| Value{ .mapping = x },
345353 .sequence => |x| Value{ .sequence = x },
346354 .string => |x| Value{ .string = x },
355 .anchor => |x| Value{ .anchor = x },
347356 else => unreachable,
348357 };
349358}