aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/reflect/value.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/reflect/value.go b/src/reflect/value.go
index 9670d4656b..7890c125d8 100644
--- a/src/reflect/value.go
+++ b/src/reflect/value.go
@@ -2702,9 +2702,14 @@ func New(typ Type) Value {
panic("reflect: New(nil)")
}
t := typ.(*rtype)
+ pt := t.ptrTo()
+ if ifaceIndir(pt) {
+ // This is a pointer to a go:notinheap type.
+ panic("reflect: New of type that may not be allocated in heap (possibly undefined cgo C type)")
+ }
ptr := unsafe_New(t)
fl := flag(Ptr)
- return Value{t.ptrTo(), ptr, fl}
+ return Value{pt, ptr, fl}
}
// NewAt returns a Value representing a pointer to a value of the