# std.json: avoid stale pointers when parsing Value \(\#16864\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/f3f554b9b89cc39cf00b4df68bd3455e8ef34984)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: f3f554b9b89cc39cf00b4df68bd3455e8ef34984

Requested commit: f3f554b9b89cc39cf00b4df68bd3455e8ef34984

Commit: f3f554b9b89cc39cf00b4df68bd3455e8ef34984

Tree: 819fed8d1bd38c4d6ce10dbdf1cc3def7aec5636

Author: Ian Johnson

Committer: GitHub

## Message

```
std.json: avoid stale pointers when parsing Value (#16864)

Closes #16861

Using `alloc_if_needed` when parsing a `Value` allows receiving a token
which points to the buffer of the underlying `Reader`. This token will
no longer be valid after the `Reader`'s buffer is refilled, which will
happen with large values. Using `alloc_always` avoids this issue by
ensuring the returned tokens always own their data independently of the
underlying buffer.
```

## Parents

- [5395c2786a2ea9fd70e8c91aab099976216089aa](https://git.cafe/gitcafe/zig/commit/5395c2786a2ea9fd70e8c91aab099976216089aa?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/f3f554b9b89cc39cf00b4df68bd3455e8ef34984?format=markdown)
