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:...@@ -1535,7 +1535,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
1535 const allocator = options.allocator orelse return error.AllocatorRequired;1535 const allocator = options.allocator orelse return error.AllocatorRequired;
1536 switch (ptrInfo.size) {1536 switch (ptrInfo.size) {
1537 .One => {1537 .One => {
1538 const r: T = allocator.create(ptrInfo.child);1538 const r: T = try allocator.create(ptrInfo.child);
1539 r.* = try parseInternal(ptrInfo.child, token, tokens, options);1539 r.* = try parseInternal(ptrInfo.child, token, tokens, options);
1540 return r;1540 return r;
1541 },1541 },
...@@ -1629,7 +1629,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void {...@@ -1629,7 +1629,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void {
1629 switch (ptrInfo.size) {1629 switch (ptrInfo.size) {
1630 .One => {1630 .One => {
1631 parseFree(ptrInfo.child, value.*, options);1631 parseFree(ptrInfo.child, value.*, options);
1632 allocator.destroy(v);1632 allocator.destroy(value);
1633 },1633 },
1634 .Slice => {1634 .Slice => {
1635 for (value) |v| {1635 for (value) |v| {