]> Cypherpunks repositories - gostls13.git/commit
encoding/json: fix Unmarshal hang on recursive pointers
authorLE Manh Cuong <cuong.manhle.vn@gmail.com>
Mon, 29 Apr 2019 15:57:25 +0000 (22:57 +0700)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 30 Apr 2019 04:57:42 +0000 (04:57 +0000)
commitdcb84828a6b1d7d4d9186bc6d752cc147e255162
tree574e4bcff325b36f0577d59bfb0873e33c42e9b9
parentd021dd6a3fe61059094dba591aba265cbf6f7733
encoding/json: fix Unmarshal hang on recursive pointers

indirect walks down v until it gets to a non-pointer. But it does not
handle the case when v is a pointer to itself, like in:

var v interface{}
v = &v
Unmarshal(b, v)

So just stop immediately if we see v is a pointer to itself.

Fixes #31740

Change-Id: Ie396264119e24d70284cd9bf76dcb2050babb069
Reviewed-on: https://go-review.googlesource.com/c/go/+/174337
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/encoding/json/decode.go
src/encoding/json/decode_test.go