diff options
author | rowanbeentje <rowan@beent.je> | 2010-03-15 00:15:23 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-03-15 00:15:23 +0000 |
commit | 5a6d0f17bbf6b09463b908182dc2cbb112a0c6cb (patch) | |
tree | 4eb9575d7de321fc6f454892d0df13ddc4b6ce39 | |
parent | 927784129ffd4d30e35f92a3fe6a8582219c64db (diff) | |
download | sequelpro-5a6d0f17bbf6b09463b908182dc2cbb112a0c6cb.tar.gz sequelpro-5a6d0f17bbf6b09463b908182dc2cbb112a0c6cb.tar.bz2 sequelpro-5a6d0f17bbf6b09463b908182dc2cbb112a0c6cb.zip |
Following a manual code review, fix some local variables overriding global variables, a few leaks, and additional nil setting/checking to prevent overreleases or releases of random areas of memory.
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 1 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPResult.m | 12 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m | 2 | ||||
-rw-r--r-- | Source/CMCopyTable.m | 2 | ||||
-rw-r--r-- | Source/CustomQuery.m | 2 | ||||
-rw-r--r-- | Source/ImageAndTextCell.m | 8 | ||||
-rw-r--r-- | Source/MGTemplateStandardMarkers.m | 1 | ||||
-rw-r--r-- | Source/SPAppController.m | 1 | ||||
-rw-r--r-- | Source/SPDatabaseData.m | 2 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 3 | ||||
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 1 | ||||
-rw-r--r-- | Source/SPTableData.m | 22 | ||||
-rw-r--r-- | Source/TableContent.m | 1 | ||||
-rw-r--r-- | Source/TableDocument.m | 12 | ||||
-rw-r--r-- | Source/TableSource.m | 3 |
15 files changed, 48 insertions, 25 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 19624652..f04fe226 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -105,6 +105,7 @@ static BOOL sTruncateLongFieldInLogs = YES; queryCancelled = NO; queryCancelUsedReconnect = NO; serverVersionString = nil; + mTimeZone = nil; // Initialize ivar defaults connectionTimeout = 10; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m index 4e3fef3a..be8a85eb 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m @@ -253,7 +253,7 @@ const OUR_CHARSET our_charsets60[] = if (mNames) { [mNames release]; - mNames = NULL; + mNames = nil; } mNumOfFields = 0; @@ -280,7 +280,7 @@ const OUR_CHARSET our_charsets60[] = if (mNames) { [mNames release]; - mNames = NULL; + mNames = nil; } mResult = mysql_store_result(mySQLPtr); @@ -315,7 +315,7 @@ const OUR_CHARSET our_charsets60[] = if (mNames) { [mNames release]; - mNames = NULL; + mNames = nil; } mResult = mySQLResPtr; @@ -874,7 +874,7 @@ const OUR_CHARSET our_charsets60[] = return (0); } - if (mNames == NULL) { + if (mNames == nil) { [self fetchFieldNames]; } @@ -959,7 +959,7 @@ const OUR_CHARSET our_charsets60[] = return (NO); } - if (mNames == NULL) { + if (mNames == nil) { [self fetchFieldNames]; } @@ -1342,7 +1342,7 @@ const OUR_CHARSET our_charsets60[] = - (void) dealloc { if (mResult) mysql_free_result(mResult); - if (mNames) [mNames autorelease]; + if (mNames) [mNames release]; if (mTimeZone) [mTimeZone release]; [super dealloc]; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m index 58a8c3a6..624f132c 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m @@ -83,7 +83,7 @@ if (mNames) { [mNames release]; - mNames = NULL; + mNames = nil; } mResult = mysql_use_result(mySQLPtr); diff --git a/Source/CMCopyTable.m b/Source/CMCopyTable.m index cc917dba..dc9cc770 100644 --- a/Source/CMCopyTable.m +++ b/Source/CMCopyTable.m @@ -85,7 +85,7 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2002; } if ( [anItem tag] == MENU_EDIT_COPY_AS_SQL ) { - return (columnDefinitions != NULL && [self selectedRow] > -1); + return (columnDefinitions != nil && [self selectedRow] > -1); } return YES; } diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 73db6bc6..1427291c 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -3101,6 +3101,7 @@ sortColumn = nil; selectionButtonCanBeEnabled = NO; cqColumnDefinition = nil; + favoritesManager = nil; tableRowsSelectable = YES; selectionIndexToRestore = nil; @@ -3249,6 +3250,7 @@ if (sortField) [sortField release]; if (cqColumnDefinition) [cqColumnDefinition release]; if (selectionIndexToRestore) [selectionIndexToRestore release]; + if (currentQueryRanges) [currentQueryRanges release]; [super dealloc]; } diff --git a/Source/ImageAndTextCell.m b/Source/ImageAndTextCell.m index 51834825..eb2f6678 100644 --- a/Source/ImageAndTextCell.m +++ b/Source/ImageAndTextCell.m @@ -9,6 +9,14 @@ @implementation ImageAndTextCell +- (id)init +{ + self = [super init]; + image = nil; + + return self; +} + - (void)dealloc { [image release]; image = nil; diff --git a/Source/MGTemplateStandardMarkers.m b/Source/MGTemplateStandardMarkers.m index 1bf00f7c..0cbc8c66 100644 --- a/Source/MGTemplateStandardMarkers.m +++ b/Source/MGTemplateStandardMarkers.m @@ -613,6 +613,7 @@ ifStack = [[NSMutableArray alloc] init]; [commentStack release]; commentStack = [[NSMutableArray alloc] init]; + [cycles release]; cycles = [[NSMutableDictionary alloc] init]; } diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 5a515f02..23379761 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -67,6 +67,7 @@ [[SUUpdater sharedUpdater] setDelegate:self]; prefsController = [[SPPreferenceController alloc] init]; + aboutController = nil; // Register SPAppController as services provider [NSApp setServicesProvider:self]; diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m index c3649328..78b4295e 100644 --- a/Source/SPDatabaseData.m +++ b/Source/SPDatabaseData.m @@ -217,7 +217,7 @@ const CHAR_SETS charsets[] = - (void)resetAllData { if (characterSetEncoding != nil) { - [characterSetEncoding release]; + [characterSetEncoding release], characterSetEncoding = nil; } [collations removeAllObjects]; diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 7b52bbf8..2db46a10 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -43,6 +43,7 @@ (void) [self window]; counter = 0; maxTextLength = 0; + stringValue = nil; prefs = [NSUserDefaults standardUserDefaults]; @@ -262,7 +263,7 @@ else [editSheet makeFirstResponder:editImage]; - [stringValue release]; + [stringValue release], stringValue = nil; } editSheetWillBeInitialized = NO; diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 6667f848..5f01d128 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -513,6 +513,7 @@ if(newFiltered) [newFiltered release]; NSLog(@"%@", @"Couldn't filter suggestion due to internal regexp error"); closeMe = YES; + return; } } diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 20a3dbd7..459406fc 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -313,9 +313,9 @@ - (NSDictionary *) informationForTable:(NSString *)tableName { SPSQLParser *createTableParser, *fieldsParser, *fieldParser; - NSMutableArray *tableColumns, *fieldStrings, *definitionParts; + NSMutableArray *tableColumns, *fieldStrings; NSMutableDictionary *tableColumn, *tableData; - NSString *encodingString; + NSString *encodingString = nil; NSUInteger i, stringStart; unichar quoteCharacter; @@ -366,7 +366,6 @@ // table information. Proceed further by parsing the field strings. tableColumns = [[NSMutableArray alloc] init]; tableColumn = [[NSMutableDictionary alloc] init]; - definitionParts = [[NSMutableArray alloc] init]; fieldParser = [[SPSQLParser alloc] init]; NSCharacterSet *whitespaceAndNewlineSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; @@ -384,7 +383,6 @@ continue; } [tableColumn removeAllObjects]; - [definitionParts removeAllObjects]; // If the first character is a quote character, this is a field definition. if ([quoteSet characterIsMember:[fieldsParser characterAtIndex:0]]) { @@ -535,9 +533,9 @@ if([parsedString length]>4) { NSString *priFieldName = [[parsedString substringWithRange:NSMakeRange(2,[parsedString length]-4)] stringByReplacingOccurrencesOfString:@"``" withString:@"`"]; [tableData setObject:priFieldName forKey:@"primarykeyfield"]; - for(id tableColumn in tableColumns) - if([[tableColumn objectForKey:@"name"] isEqualToString:priFieldName]) { - [tableColumn setObject:[NSNumber numberWithInteger:1] forKey:@"isprimarykey"]; + for(id theTableColumn in tableColumns) + if([[theTableColumn objectForKey:@"name"] isEqualToString:priFieldName]) { + [theTableColumn setObject:[NSNumber numberWithInteger:1] forKey:@"isprimarykey"]; break; } } @@ -550,9 +548,9 @@ NSArray *uniqueFieldNames = [parsedString componentsSeparatedByString:@"`,`"]; for(NSString* uniq in uniqueFieldNames) { NSString *uniqField = [[uniq stringByReplacingOccurrencesOfRegex:@"^\\(`|`\\)" withString:@""] stringByReplacingOccurrencesOfString:@"``" withString:@"`"]; - for(id tableColumn in tableColumns) - if([[tableColumn objectForKey:@"name"] isEqualToString:uniqField]) { - [tableColumn setObject:[NSNumber numberWithInteger:1] forKey:@"unique"]; + for(id theTableColumn in tableColumns) + if([[theTableColumn objectForKey:@"name"] isEqualToString:uniqField]) { + [theTableColumn setObject:[NSNumber numberWithInteger:1] forKey:@"unique"]; break; } } @@ -567,7 +565,6 @@ } [fieldStrings release]; [fieldsParser release]; - [definitionParts release]; [tableColumn release]; // Extract the encoding from the table properties string - other details come from TABLE STATUS. @@ -610,7 +607,7 @@ tableName, [mySQLConnection getLastErrorMessage]]); } [tableColumns release]; - [encodingString release]; + if (encodingString) [encodingString release]; return nil; } @@ -707,6 +704,7 @@ } // Retrieve the table syntax string + if (tableCreateSyntax) [tableCreateSyntax release], tableCreateSyntax = nil; tableCreateSyntax = [[NSString alloc] initWithString:[[theResult fetchRowAsArray] objectAtIndex:1]]; // Retrieve the SHOW COLUMNS syntax for the table diff --git a/Source/TableContent.m b/Source/TableContent.m index 793883f8..4c9336d8 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -89,6 +89,7 @@ firstBetweenValueToRestore = nil; secondBetweenValueToRestore = nil; tableRowsSelectable = YES; + contentFilterManager = nil; isFiltered = NO; isLimited = NO; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 443cadbb..2d75a8d9 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -80,6 +80,8 @@ selectedDatabase = nil; mySQLConnection = nil; mySQLVersion = nil; + allDatabases = nil; + allSystemDatabases = nil; printWebView = [[WebView alloc] init]; [printWebView setFrameLoadDelegate:self]; @@ -1043,7 +1045,7 @@ } // Close error status sheet for OPTIMIZE, CHECK, REPAIR etc. else if ([contextInfo isEqualToString:@"statusError"]) { - if(statusValues) [statusValues release]; statusValues = nil; + if (statusValues) [statusValues release], statusValues = nil; } } @@ -1200,7 +1202,7 @@ */ - (void) showTaskProgressWindow:(NSTimer *)theTimer { - [taskDrawTimer release], taskDrawTimer = nil; + if (taskDrawTimer) [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil; // Center the task window and fade it in [self centerTaskWindow]; @@ -1775,6 +1777,7 @@ contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); + if (statusValues) [statusValues release], statusValues = nil; statusValues = [result retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -1850,6 +1853,7 @@ contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); + if (statusValues) [statusValues release], statusValues = nil; statusValues = [result retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -1925,6 +1929,7 @@ contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); + if (statusValues) [statusValues release], statusValues = nil; statusValues = [result retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -1999,6 +2004,7 @@ contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); + if (statusValues) [statusValues release], statusValues = nil; statusValues = [result retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -2073,6 +2079,7 @@ contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); + if (statusValues) [statusValues release], statusValues = nil; statusValues = [result retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -2128,6 +2135,7 @@ contextInfo:NULL]; } else { NSDictionary *result = [theResult fetch2DResultAsType:MCPTypeDictionary]; + if (statusValues) [statusValues release], statusValues = nil; statusValues = [result retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Checksums of %@",@"Checksums of %@ message"), what]]; diff --git a/Source/TableSource.m b/Source/TableSource.m index 7c5f6ab4..c5e2a4b8 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -118,6 +118,7 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"), errorMessage]); + if (tableSourceResult) [tableSourceResult release]; return; } @@ -148,7 +149,7 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"), errorMessage]); - + if (indexResult) [indexResult release]; return; } [indexResult setReturnDataAsStrings:YES]; |