From e98e4c403fde04b8d6a09f36336a43ec0da6e002 Mon Sep 17 00:00:00 2001 From: Anton Sokolchenko Date: Wed, 9 Apr 2014 12:00:15 +0300 Subject: [PATCH] Potential leak of an object stored into "self" 1. By executing 314: _systemControl = [[CCEditBoxImplIOS_objc alloc] initWithFrame:rect editBox:this]; 2. We entered to the function 67: -(id) initWithFrame: (CGRect) frameRect editBox: (void*) editBox 3. Then 69: "self = [super init];" returns object with +1 retain count 4. 93: "return nil" Potential leak of an object stored into "self". --- extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm index d2ba95be02..bd41fea92d 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm @@ -67,13 +67,11 @@ static const int CC_EDIT_BOX_PADDING = 5; -(id) initWithFrame: (CGRect) frameRect editBox: (void*) editBox { self = [super init]; - - do - { - if (self == nil) break; + if(self){ editState_ = NO; self.textField = [[[CCCustomUITextField alloc] initWithFrame: frameRect] autorelease]; - if (!textField_) break; + //TODO: what is the line below doing? + //if (!textField_) break; [textField_ setTextColor:[UIColor whiteColor]]; textField_.font = [UIFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here. textField_.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; @@ -84,13 +82,9 @@ static const int CC_EDIT_BOX_PADDING = 5; textField_.returnKeyType = UIReturnKeyDefault; [textField_ addTarget:self action:@selector(textChanged) forControlEvents:UIControlEventEditingChanged]; self.editBox = editBox; - - - - return self; - }while(0); + } - return nil; + return self; } -(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance