Fix some memory issues

This commit is contained in:
Jens Ayton 2013-06-30 14:37:13 +02:00
parent 563660674a
commit 4b3886abb3
2 changed files with 12 additions and 3 deletions

View File

@ -191,9 +191,17 @@ static void ThrowAbstractionViolationException(id obj) GCC_ATTR((noreturn));
weights = [plist oo_arrayForKey:kWeightsKey]; weights = [plist oo_arrayForKey:kWeightsKey];
// Validate // Validate
if (objects == nil || weights == nil) return nil; if (objects == nil || weights == nil)
{
[self release];
return nil;
}
count = [objects count]; count = [objects count];
if (count != [weights count]) return nil; if (count != [weights count])
{
[self release];
return nil;
}
// Extract contents. // Extract contents.
rawObjects = malloc(sizeof *rawObjects * count); rawObjects = malloc(sizeof *rawObjects * count);
@ -214,6 +222,7 @@ static void ThrowAbstractionViolationException(id obj) GCC_ATTR((noreturn));
} }
else else
{ {
[self release];
self = nil; self = nil;
} }

View File

@ -163,9 +163,9 @@ static NSMutableSet *sPlayingSoundSources;
[_channel setDelegate:[self class]]; [_channel setDelegate:[self class]];
[_channel stop]; [_channel stop];
_channel = nil; _channel = nil;
[self release];
[sPlayingSoundSources removeObject:self]; [sPlayingSoundSources removeObject:self];
[self release];
} }
OOSoundReleaseLock(); OOSoundReleaseLock();