Fixed a leak in the json parser.

parseString() created a copy of the string using the wrong allocator.
Instead of using the ArenaAllocator, it was using the allocator passed
into Parser.init(). This lead to a leak as the copied string was not
freed when the ArenaAllocator was deinited.
This commit is contained in:
Sebastian Keller 2019-11-06 01:42:07 +01:00 committed by Andrew Kelley
parent 6b61fcddfa
commit dd4e9fb16b

View File

@ -1339,7 +1339,7 @@ pub const Parser = struct {
// TODO: We don't strictly have to copy values which do not contain any escape
// characters if flagged with the option.
const slice = token.slice(input, i);
return Value{ .String = try mem.dupe(p.allocator, u8, slice) };
return Value{ .String = try mem.dupe(allocator, u8, slice) };
}
fn parseNumber(p: *Parser, token: Token, input: []const u8, i: usize) !Value {