reflect: Copy stack values onto heap in amd64 MakeFunc.

From-SVN: r202995
This commit is contained in:
Ian Lance Taylor 2013-09-27 22:13:11 +00:00
parent a84dbde7fc
commit 5f18389f4d

View file

@ -431,8 +431,14 @@ argloop:
func amd64Memarg(in []Value, ap uintptr, rt *rtype) ([]Value, uintptr) {
ap = align(ap, ptrSize)
ap = align(ap, uintptr(rt.align))
p := Value{rt, unsafe.Pointer(ap), flag(rt.Kind()<<flagKindShift) | flagIndir}
in = append(in, p)
// We have to copy the argument onto the heap in case the
// function hangs onto the reflect.Value we pass it.
p := unsafe_New(rt)
memmove(p, unsafe.Pointer(ap), rt.size)
v := Value{rt, p, flag(rt.Kind()<<flagKindShift) | flagIndir}
in = append(in, v)
ap += rt.size
return in, ap
}