diff options
| author | prime31 <mike@prime31.com> | 2020-06-22 07:30:02 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-22 17:30:02 +0300 |
| commit | 65ef74e2cdc87888d16ad207371cfd3ff8c0dce1 (patch) | |
| tree | a8d57f87ad10384d21fc13b76cdac9a9bc8a8c4d /lib/std/json.zig | |
| parent | d907f574e02aadf8196e616bcc2fb2813cf2c82c (diff) | |
| download | zig-65ef74e2cdc87888d16ad207371cfd3ff8c0dce1.tar.gz zig-65ef74e2cdc87888d16ad207371cfd3ff8c0dce1.zip | |
`try` allocation of pointer type when parsing (#5665)
* `try` allocation of pointer type when parsing
* fixes pointer destroy compile error
Diffstat (limited to 'lib/std/json.zig')
| -rw-r--r-- | lib/std/json.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/json.zig b/lib/std/json.zig index ae10dc9559..6377b69a80 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -1535,7 +1535,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: const allocator = options.allocator orelse return error.AllocatorRequired; switch (ptrInfo.size) { .One => { - const r: T = allocator.create(ptrInfo.child); + const r: T = try allocator.create(ptrInfo.child); r.* = try parseInternal(ptrInfo.child, token, tokens, options); return r; }, @@ -1629,7 +1629,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { switch (ptrInfo.size) { .One => { parseFree(ptrInfo.child, value.*, options); - allocator.destroy(v); + allocator.destroy(value); }, .Slice => { for (value) |v| { |
