authorgravatar for mike@prime31.comprime31 <mike@prime31.com> 2020-06-22 07:30:02-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-06-22 17:30:02+03:00
log65ef74e2cdc87888d16ad207371cfd3ff8c0dce1
treea8d57f87ad10384d21fc13b76cdac9a9bc8a8c4d
parentd907f574e02aadf8196e616bcc2fb2813cf2c82c
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

`try` allocation of pointer type when parsing (#5665)

* `try` allocation of pointer type when parsing * fixes pointer destroy compile error

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/json.zig+2-2
......@@ -1535,7 +1535,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
15351535 const allocator = options.allocator orelse return error.AllocatorRequired;
15361536 switch (ptrInfo.size) {
15371537 .One => {
1538 const r: T = allocator.create(ptrInfo.child);
1538 const r: T = try allocator.create(ptrInfo.child);
15391539 r.* = try parseInternal(ptrInfo.child, token, tokens, options);
15401540 return r;
15411541 },
......@@ -1629,7 +1629,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void {
16291629 switch (ptrInfo.size) {
16301630 .One => {
16311631 parseFree(ptrInfo.child, value.*, options);
1632 allocator.destroy(v);
1632 allocator.destroy(value);
16331633 },
16341634 .Slice => {
16351635 for (value) |v| {