From 3c17e185e9936ba66e9be5ab3dccb38f7a1f4d20 Mon Sep 17 00:00:00 2001 From: rfm Date: Wed, 17 Mar 2010 11:28:04 +0000 Subject: [PATCH] attempt memory leak fix git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29993 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 ++++++++++ Source/NSConnection.m | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5ab6f71cb..7afa2eb7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-03-17 Richard Frith-Macdonald + + * Source/NSConnection.m: Fix for memory leak ... autorelease + objects returned by method in remote process because the invocation + won't do it for us (we call -setReturnValue: which will have the invocation + retain the object, so when it releases it again later the retain count is + the same as at the point when we decoded the object, and another release + is needed). + I'm not certain this fix is right, but it seems ok. + 2010-03-13 Yavor Doganov (tiny change) * Source/NSCalendarDate.m (outputValueWithFormat) diff --git a/Source/NSConnection.m b/Source/NSConnection.m index 4821f15ed..d63f4a9db 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -2105,11 +2105,18 @@ static NSLock *cached_proxies_gate = nil; /* xxx What happens with method declared "- (in char *) bar;" */ /* xxx Is this right? Do we also have to check _F_ONEWAY? */ { + id obj; + /* If there is a return value, decode it, and put it in datum. */ if (*tmptype != _C_VOID || (flags & _F_ONEWAY) == 0) { switch (*tmptype) { + case _C_ID: + datum = &obj; + [aRmc decodeValueOfObjCType: tmptype at: datum]; + [obj autorelease]; + break; case _C_PTR: /* We are returning a pointer to something. */ tmptype++; @@ -2151,7 +2158,7 @@ static NSLock *cached_proxies_gate = nil; if (*tmptype == _C_PTR && ((flags & _F_OUT) || !(flags & _F_IN))) { - /* If the arg was myref, we obtain its address + /* If the arg was byref, we obtain its address * and decode the data directly to it. */ tmptype++;