Fix leaks

This commit is contained in:
rfm 2025-01-09 09:19:03 +00:00
parent cf8c387900
commit 6f7a4d74c2
3 changed files with 12 additions and 5 deletions

View file

@ -837,7 +837,7 @@ _arg_addr(NSInvocation *inv, int index)
+ (NSInvocation*) _returnInvocationAndDestroyProxy: (id)proxy
{
NSInvocation *inv = [proxy _invocation];
NSDeallocateObject(proxy);
[proxy dealloc];
return inv;
}
@end
@ -888,6 +888,11 @@ _arg_addr(NSInvocation *inv, int index)
o->target = RETAIN(t);
return o;
}
- (void) dealloc
{
DESTROY(target);
NSDeallocateObject(self);
}
- (NSInvocation*) _invocation
{
return invocation;

View file

@ -78,8 +78,8 @@ int main()
pClass = NSClassFromString(@"InvokeProxy");
tar = [tClass new];
pxy = [[pClass alloc] initWithTarget:tar];
tar = AUTORELEASE([tClass new]);
pxy = AUTORELEASE([[pClass alloc] initWithTarget:tar]);
TEST_INVOKE(@selector(retChar));
[inv getReturnValue:&cret];
PASS(cret == 99 &&
@ -207,6 +207,8 @@ int main()
PASS(NSEqualRects(rret, rarg) && NSEqualRects(rprx, rarg),
"Can send/return NSRect");
free(cparg);
free(cparg2);
[arp release]; arp = nil;
return 0;
}

View file

@ -19,8 +19,8 @@ static int called = 0;
int main(void)
{
NSAutoreleasePool* pool = [NSAutoreleasePool new];
NSMessageTest* test = [NSMessageTest new];
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSMessageTest *test = AUTORELEASE([NSMessageTest new]);
[NS_MESSAGE(test, methodToCall) invoke];