Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Yaml.zig
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn parseValue(self: Yaml, arena: Allocator, comptime T: type, value: Value) Erro
return self.parsePointer(arena, T, .{ .list = list });
} else |_| {
const scalar = try value.asScalar();
return self.parsePointer(arena, T, .{ .scalar = try arena.dupe(u8, scalar) });
return self.parsePointer(arena, T, .{ .scalar = scalar });
},
.void => error.TypeMismatch,
.optional => unreachable,
Expand Down Expand Up @@ -177,6 +177,7 @@ fn parseStruct(self: Yaml, arena: Allocator, comptime T: type, map: Map) Error!T
inline for (struct_info.fields) |field| {
var value: ?Value = map.get(field.name) orelse blk: {
const field_name = try mem.replaceOwned(u8, arena, field.name, "_", "-");
defer arena.free(field_name);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this looks sus to me. Why would we need to specifically free field_name if it's allocated in an arena and hence should be freed upon freeing the entire arena.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but if you look at the error, you'll see that GPA does complain.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When reporting the issue, did you use an arena, or did you pass a GPA instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A GPA

break :blk map.get(field_name);
};

Expand Down