]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: fix Zero() implementation - not every type has a
authorKeith Randall <khr@golang.org>
Tue, 3 Dec 2013 00:54:29 +0000 (16:54 -0800)
committerKeith Randall <khr@golang.org>
Tue, 3 Dec 2013 00:54:29 +0000 (16:54 -0800)
zero object allocated, so we still need to allocate a new
zero area every time.

Fixes #6876.

R=golang-dev
CC=golang-dev
https://golang.org/cl/36320043

src/pkg/reflect/value.go

index 7e709e62072ca7f7879a0a06a64d62005a7e39bd..7764ffade2c2681936848177a26879fdf72a4a54 100644 (file)
@@ -2175,7 +2175,7 @@ func Zero(typ Type) Value {
        if t.size <= ptrSize {
                return Value{t, nil, fl}
        }
-       return Value{t, t.zero, fl | flagIndir}
+       return Value{t, unsafe_New(typ.(*rtype)), fl | flagIndir}
 }
 
 // New returns a Value representing a pointer to a new zero value