]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
reflect: Copy stack values onto heap in amd64 MakeFunc.
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 27 Sep 2013 22:13:11 +0000 (22:13 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 27 Sep 2013 22:13:11 +0000 (22:13 +0000)
From-SVN: r202995

libgo/go/reflect/makefuncgo_amd64.go

index bdc655605061203f1ee7793a74c369379b4c7d91..ecc50a42520aeaf977ec2ff326974cb9b74a0424 100644 (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
 }