]> Cypherpunks repositories - gostls13.git/commit
encoding/json: always check resulting Go value for unmarshaling
authorJoe Tsai <joetsai@digital-static.net>
Fri, 10 Jan 2025 19:49:07 +0000 (11:49 -0800)
committerGopher Robot <gobot@golang.org>
Mon, 13 Jan 2025 16:27:19 +0000 (08:27 -0800)
commit7bb192a1c56e2961b3eeffb8250615e395c903d4
tree65959eceaf1c36ec1f3791ca85050bb169381151
parent44a6f817ea0fbeb3ba4aa398794c4e80dba13b1e
encoding/json: always check resulting Go value for unmarshaling

Even if an error occurs during unmarshal, check the resulting Go value.
The documented API specifies no guarantees on how much of a Go value
will be populated when an error occurs and the "json" package
is technically not bounded by the Go compatibility agreement
to ensure this behavior never changes.

However, there is still value in running checks for
what exactly what is partially mutated in the event of an error
even if this is not guaranteed behavior.

Change-Id: I6e923a31f77768a14c4adfb0d37dbeee5807a4a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/642275
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/encoding/json/decode_test.go