aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/decode.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/json/decode.go')
-rw-r--r--src/encoding/json/decode.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/encoding/json/decode.go b/src/encoding/json/decode.go
index 3ca3d7803e..bdd94e34ce 100644
--- a/src/encoding/json/decode.go
+++ b/src/encoding/json/decode.go
@@ -535,6 +535,14 @@ func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnm
if v.Elem().Kind() != reflect.Ptr && decodingNull && v.CanSet() {
break
}
+
+ // Prevent infinite loop if v is an interface pointing to its own address:
+ // var v interface{}
+ // v = &v
+ if v.Elem().Kind() == reflect.Interface && v.Elem().Elem() == v {
+ v = v.Elem()
+ break
+ }
if v.IsNil() {
v.Set(reflect.New(v.Type().Elem()))
}