]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: initialize ptrdata earlier in StructOf
authorKeith Randall <keithr@alum.mit.edu>
Tue, 26 Mar 2019 03:29:18 +0000 (20:29 -0700)
committerKeith Randall <khr@golang.org>
Tue, 26 Mar 2019 03:54:07 +0000 (03:54 +0000)
It needs to be set before addTypeBits is called.

Fixes #31043

Change-Id: I692b4047dc17bd68202d45da41dd55d432383e59
Reviewed-on: https://go-review.googlesource.com/c/go/+/169318
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/reflect/type.go

index 10509ac418373b404c411126b109e944b2a9bb72..83e59014edae09feb04177ff742ec31b69c3cd3b 100644 (file)
@@ -2639,6 +2639,7 @@ func StructOf(fields []StructField) Type {
        typ.tflag = 0
        typ.hash = hash
        typ.size = size
+       typ.ptrdata = typeptrdata(typ.common())
        typ.align = typalign
        typ.fieldAlign = typalign
        typ.ptrToThis = 0
@@ -2709,7 +2710,6 @@ func StructOf(fields []StructField) Type {
                        typ.gcdata = &bv.data[0]
                }
        }
-       typ.ptrdata = typeptrdata(typ.common())
        typ.alg = new(typeAlg)
        if hashable {
                typ.alg.hash = func(p unsafe.Pointer, seed uintptr) uintptr {