Permalink
Browse files

Be sure to return nil when port creation fails

  • Loading branch information...
1 parent 1d02b67 commit 03228b362b522fca1593d405287d5bd91a8f0eb4 Jonathan del Strother committed Sep 16, 2009
Showing with 8 additions and 1 deletion.
  1. +6 −1 BBOSCInPort.m
  2. +2 −0 BBOSCManager.m
View
@@ -11,9 +11,14 @@
@implementation BBOSCInPort
-(id)initWithManager:(OSCManager*)manager withPort:(unsigned int)p label:(NSString*)l {
+ OSCInPort* newPort = [manager createNewInputForPort:p withLabel:l];
+ if (!newPort) {
+ [self release];
+ return nil;
+ }
if (self = [super init]) {
oscManager = [manager retain];
- oscPort = [[oscManager createNewInputForPort:p withLabel:l] retain];
+ oscPort = [newPort retain];
oscPort.delegate = self;
delegates = [[NSMutableSet alloc] init];
}
View
@@ -77,6 +77,8 @@ - (BBOSCInPort *) createNewInputForPort:(int)p withLabel:(NSString *)l {
if (!resultingPort) {
resultingPort = [[[BBOSCInPort alloc] initWithManager:oscManager withPort:p label:l] autorelease];
+ if (!resultingPort)
+ return nil;
}
// This is a counted set, so we always add the port, so we can keep track of how many people are using it.

0 comments on commit 03228b3

Please sign in to comment.