aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/stream.go
diff options
context:
space:
mode:
authoritchyny <itchyny@hatena.ne.jp>2019-09-02 00:07:40 +0000
committerDaniel Martí <mvdan@mvdan.cc>2019-09-02 11:00:29 +0000
commit7450960a1300a6f81da2abac63fcfbe0bccc6c50 (patch)
treef5f8dd313546fe3a4805cc0129a3e47038faddc7 /src/encoding/json/stream.go
parent9c295bdeabb47891e216139d88881613a52514b8 (diff)
downloadgo-7450960a1300a6f81da2abac63fcfbe0bccc6c50.tar.xz
encoding/json: fix scanner byte offset on scanEnd
scanEnd is delayed one byte so we decrement the scanner bytes count by 1 to ensure that this value is correct in the next call of Decode. Fixes #32399 Change-Id: I8c8698e7f95bbcf0373aceaa05319819eae9d86f GitHub-Last-Rev: 0ac25d8de23d38c7ac577faddc6983571023f561 GitHub-Pull-Request: golang/go#32598 Reviewed-on: https://go-review.googlesource.com/c/go/+/182117 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/encoding/json/stream.go')
-rw-r--r--src/encoding/json/stream.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/encoding/json/stream.go b/src/encoding/json/stream.go
index e29127499b..3d30322ce2 100644
--- a/src/encoding/json/stream.go
+++ b/src/encoding/json/stream.go
@@ -102,6 +102,10 @@ Input:
dec.scan.bytes++
switch dec.scan.step(&dec.scan, c) {
case scanEnd:
+ // scanEnd is delayed one byte so we decrement
+ // the scanner bytes count by 1 to ensure that
+ // this value is correct in the next call of Decode.
+ dec.scan.bytes--
break Input
case scanEndObject, scanEndArray:
// scanEnd is delayed one byte.