diff options
author | rowanbeentje <rowan@beent.je> | 2010-02-10 01:32:05 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-02-10 01:32:05 +0000 |
commit | 13805614e6ed2131827bfa6c668b50a1b30da1e5 (patch) | |
tree | 8142178495af47518a2d693950d8623eec2ff2b5 /Source | |
parent | d0fb716108641d3a8c197ef12041bf46b14e7294 (diff) | |
download | sequelpro-13805614e6ed2131827bfa6c668b50a1b30da1e5.tar.gz sequelpro-13805614e6ed2131827bfa6c668b50a1b30da1e5.tar.bz2 sequelpro-13805614e6ed2131827bfa6c668b50a1b30da1e5.zip |
Fix a number of memory leaks, and over-releases, as both a result of manual inspection of leaks and Clang static analysis.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMTextView.m | 4 | ||||
-rw-r--r-- | Source/SPContentFilterManager.m | 2 | ||||
-rw-r--r-- | Source/SPFavoriteTextFieldCell.m | 12 | ||||
-rw-r--r-- | Source/SPKeychain.m | 2 | ||||
-rw-r--r-- | Source/SPQueryController.m | 2 | ||||
-rw-r--r-- | Source/SPTableData.m | 4 | ||||
-rw-r--r-- | Source/SPTooltip.m | 2 | ||||
-rw-r--r-- | Source/TableDocument.m | 2 | ||||
-rw-r--r-- | Source/TableDump.m | 10 | ||||
-rw-r--r-- | Source/TablesList.m | 9 |
10 files changed, 30 insertions, 19 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index c95d7d1f..474b0af9 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -314,7 +314,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) // Add structural db/table/field data to completions list or fallback to gathering TablesList data NSDictionary *dbs = [NSDictionary dictionaryWithDictionary:[mySQLConnection getDbStructure]]; if(dbs != nil && [dbs count]) { - NSMutableArray *allDbs = [[NSMutableArray array] autorelease]; + NSMutableArray *allDbs = [NSMutableArray array]; [allDbs addObjectsFromArray:[dbs allKeys]]; // Add database names having no tables since they don't appear in the information_schema @@ -356,7 +356,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if(!aDbName) { // Try to suggest only items which are uniquely valid for the parsed string - NSInteger uniqueSchemaKind = [mySQLConnection getUniqueDbIndentifierFor:[aTableName lowercaseString]]; + NSInteger uniqueSchemaKind = [mySQLConnection getUniqueDbIdentifierFor:[aTableName lowercaseString]]; // If no db name but table name check if table name is a valid name in the current selected db if(aTableName && [aTableName length] && [dbs objectForKey:currentDb] && [[dbs objectForKey:currentDb] objectForKey:aTableName] && uniqueSchemaKind == 2) { diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m index 34a3b214..8e3fa5fe 100644 --- a/Source/SPContentFilterManager.m +++ b/Source/SPContentFilterManager.m @@ -792,6 +792,7 @@ // } [contentFilterArrayController rearrangeObjects]; [contentFilterTableView reloadData]; + [spf release]; } else { NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while reading data file", @"error while reading data file")] defaultButton:NSLocalizedString(@"OK", @"OK button") @@ -801,6 +802,7 @@ [alert setAlertStyle:NSInformationalAlertStyle]; [alert runModal]; + [spf release]; return; } } diff --git a/Source/SPFavoriteTextFieldCell.m b/Source/SPFavoriteTextFieldCell.m index ea460af0..355ee459 100644 --- a/Source/SPFavoriteTextFieldCell.m +++ b/Source/SPFavoriteTextFieldCell.m @@ -121,8 +121,8 @@ (([self isHighlighted]) && (![[self highlightColorWithFrame:cellFrame inView:controlView] isEqualTo:[NSColor secondarySelectedControlColor]])) ? [self invertFontColors] : [self restoreFontColors]; // Construct and get the sub text attributed string - NSAttributedString *mainString = [[self attributedStringForFavoriteName] autorelease]; - NSAttributedString *subString = [[self constructSubStringAttributedString] autorelease]; + NSAttributedString *mainString = [self attributedStringForFavoriteName]; + NSAttributedString *subString = [self constructSubStringAttributedString]; NSRect subFrame = NSMakeRect(0.0, 0.0, [subString size].width, [subString size].height); @@ -169,8 +169,8 @@ - (NSSize)cellSize { NSSize cellSize = [super cellSize]; - NSAttributedString *mainString = [[self attributedStringForFavoriteName] autorelease]; - NSAttributedString *subString = [[self constructSubStringAttributedString] autorelease]; + NSAttributedString *mainString = [self attributedStringForFavoriteName]; + NSAttributedString *subString = [self constructSubStringAttributedString]; // 15 := indention 10 from image to string plus 5 px padding CGFloat theWidth = MAX([mainString size].width, [subString size].width) + (([self image] != nil) ? [[self image] size].width : 0) + 15; @@ -225,7 +225,7 @@ // ------------------------------------------------------------------------------- - (NSAttributedString *)constructSubStringAttributedString { - return [[NSAttributedString alloc] initWithString:favoriteHost attributes:[self subStringAttributedStringAttributes]]; + return [[[NSAttributedString alloc] initWithString:favoriteHost attributes:[self subStringAttributedStringAttributes]] autorelease]; } // ------------------------------------------------------------------------------- @@ -235,7 +235,7 @@ // ------------------------------------------------------------------------------- - (NSAttributedString *)attributedStringForFavoriteName { - return [[NSAttributedString alloc] initWithString:favoriteName attributes:[self mainStringAttributedStringAttributes]]; + return [[[NSAttributedString alloc] initWithString:favoriteName attributes:[self mainStringAttributedStringAttributes]] autorelease]; } // ------------------------------------------------------------------------------- diff --git a/Source/SPKeychain.m b/Source/SPKeychain.m index 622c3a86..a6550ec6 100644 --- a/Source/SPKeychain.m +++ b/Source/SPKeychain.m @@ -45,7 +45,7 @@ { OSStatus status; SecTrustedApplicationRef sequelProRef, sequelProHelperRef; - SecAccessRef passwordAccessRef; + SecAccessRef passwordAccessRef = NULL; SecKeychainAttribute attributes[4]; SecKeychainAttributeList attList; diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index 0ff0fac7..2eddf018 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -653,7 +653,7 @@ static SPQueryController *sharedQueryController = nil; - (NSArray *)historyMenuItemsForFileURL:(NSURL *)fileURL { if([historyContainer objectForKey:[fileURL absoluteString]]) { - NSMutableArray *returnArray = [[NSMutableArray arrayWithCapacity:[[historyContainer objectForKey:[fileURL absoluteString]] count]] autorelease]; + NSMutableArray *returnArray = [NSMutableArray arrayWithCapacity:[[historyContainer objectForKey:[fileURL absoluteString]] count]]; NSMenuItem *historyMenuItem; for(id history in [historyContainer objectForKey:[fileURL absoluteString]]) { historyMenuItem = [[[NSMenuItem alloc] initWithTitle:([history length] > 64) ? [NSString stringWithFormat:@"%@…", [history substringToIndex:63]] : history diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 82b7a9da..fe13e4f3 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -583,7 +583,9 @@ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving the information for table '%@'. Please try again.\n\nMySQL said: %@", @"error retrieving table information informative message"), tableName, [mySQLConnection getLastErrorMessage]]); } - + [tableColumns release]; + [encodingString release]; + return nil; } diff --git a/Source/SPTooltip.m b/Source/SPTooltip.m index 90f4b202..07162db8 100644 --- a/Source/SPTooltip.m +++ b/Source/SPTooltip.m @@ -122,7 +122,7 @@ static CGFloat slow_in_out (CGFloat t) spTooltipCounter++; - SPTooltip* tip = [SPTooltip new]; + SPTooltip* tip = [SPTooltip new]; // Automatically released on close [tip initMeWithOptions:displayOptions]; [tip setFrameTopLeftPoint:point]; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 28a5bae8..f8c0fe69 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -848,7 +848,7 @@ [connection setValue:versionForPrint forKey:@"version"]; NSArray *columns, *rows; - columns = rows = nil; + rows = nil; columns = [self columnNames]; if ( [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 0 ){ diff --git a/Source/TableDump.m b/Source/TableDump.m index 04942462..2e055f94 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -1746,7 +1746,10 @@ NSString *procedureName = [NSString stringWithFormat:@"%@", [proceduresList objectForKey:@"Name"]]; // Only proceed if the item was selected for export - if (![selectedItems containsObject:procedureName]) continue; + if (![selectedItems containsObject:procedureName]) { + [proceduresList release]; + continue; + } // Add the "drop" command if specified in the export dialog if ([addDropTableSwitch state] == NSOnState) { @@ -1756,7 +1759,10 @@ } // Only continue if the "create syntax" is specified in the export dialog - if ([addCreateTableSwitch state] == NSOffState) continue; + if ([addCreateTableSwitch state] == NSOffState) { + [proceduresList release]; + continue; + } //Definer is user@host but we need to escape it to `user`@`host` NSArray *procedureDefiner = [[proceduresList objectForKey:@"Definer"] componentsSeparatedByString:@"@"]; diff --git a/Source/TablesList.m b/Source/TablesList.m index dd675c43..b66af9fb 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -2005,19 +2005,21 @@ } else { //insert new table name in create syntax and create new table - NSScanner *scanner = [NSScanner alloc]; + NSScanner *scanner; NSString *scanString; if(tblType == SP_TABLETYPE_VIEW){ - [scanner initWithString:[[queryResult fetchRowAsDictionary] objectForKey:@"Create View"]]; + scanner = [[NSScanner alloc] initWithString:[[queryResult fetchRowAsDictionary] objectForKey:@"Create View"]]; [scanner scanUpToString:@"AS" intoString:nil]; [scanner scanUpToString:@"" intoString:&scanString]; + [scanner release]; [mySQLConnection queryString:[NSString stringWithFormat:@"CREATE VIEW %@ %@", [[copyTableNameField stringValue] backtickQuotedString], scanString]]; } else if(tblType == SP_TABLETYPE_TABLE){ - [scanner initWithString:[[queryResult fetchRowAsDictionary] objectForKey:@"Create Table"]]; + scanner = [[NSScanner alloc] initWithString:[[queryResult fetchRowAsDictionary] objectForKey:@"Create Table"]]; [scanner scanUpToString:@"(" intoString:nil]; [scanner scanUpToString:@"" intoString:&scanString]; + [scanner release]; // If there are any InnoDB referencial constraints we need to strip out the names as they must be unique. // MySQL will generate the new names based on the new table name. @@ -2062,7 +2064,6 @@ } } - [scanner release]; if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { //error while creating new table |