diff --git a/ChangeLog b/ChangeLog index 5da69d7f4..5b85ab3ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-04-10 Richard Frith-Macdonald + + * Source/callframe.m: + * Source/cifframe.m: + Fix error in returning data via pointer arguments ... was writing to + wrong memory location. + 2003-04-09 Richard Frith-Macdonald * Source/GSTcpPort.m: diff --git a/Source/callframe.m b/Source/callframe.m index b6c02afc7..4595e5b79 100644 --- a/Source/callframe.m +++ b/Source/callframe.m @@ -674,7 +674,7 @@ callframe_build_return (NSInvocation *inv, { /* Step through all the arguments, finding the ones that were passed by reference. */ - for (tmptype = objc_skip_argspec (tmptype), argnum = 0; + for (tmptype = objc_skip_argspec (tmptype), argnum = 0; *tmptype != '\0'; tmptype = objc_skip_argspec (tmptype), argnum++) { @@ -694,9 +694,10 @@ callframe_build_return (NSInvocation *inv, ctxt->flags = flags; if (*tmptype == _C_PTR - && ((flags & _F_OUT) || !(flags & _F_IN))) + && ((flags & _F_OUT) || !(flags & _F_IN))) { void *ptr; + /* The argument is a pointer (to a non-char), and the pointer's value is qualified as an OUT parameter, or it not explicitly qualified as an @@ -705,11 +706,12 @@ callframe_build_return (NSInvocation *inv, tmptype++; ctxt->type = tmptype; - (*decoder) (ctxt); - /* Copy the pointed-to data back to the original - pointer */ + /* Use the original pointer to find the buffer + * to store the returned data */ [inv getArgument: &ptr atIndex: argnum]; - memcpy(ptr, datum, objc_sizeof_type(tmptype)); + ctxt->datum = ptr; + + (*decoder) (ctxt); } else if (*tmptype == _C_CHARPTR && ((flags & _F_OUT) || !(flags & _F_IN))) diff --git a/Source/cifframe.m b/Source/cifframe.m index 5a8934d08..c7a4fb552 100644 --- a/Source/cifframe.m +++ b/Source/cifframe.m @@ -1102,11 +1102,12 @@ cifframe_build_return (NSInvocation *inv, tmptype++; ctxt->type = tmptype; - (*decoder) (ctxt); - /* Copy the pointed-to data back to the original - pointer */ + /* Use the original pointer to find the buffer + * to store the returned data */ [inv getArgument: &ptr atIndex: argnum]; - memcpy(ptr, datum, objc_sizeof_type(tmptype)); + ctxt->datum = ptr; + + (*decoder) (ctxt); } else if (*tmptype == _C_CHARPTR && ((flags & _F_OUT) || !(flags & _F_IN)))