]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
reflect: Copy stack values onto heap in amd64 MakeFunc.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Sep 2013 22:13:11 +0000 (22:13 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Sep 2013 22:13:11 +0000 (22:13 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202995 138bc75d-0d04-0410-961f-82ee72b054a4

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
 }