1313// You should have received a copy of the GNU General Public License
1414// along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
16+ #if __has_feature(objc_arc)
17+ #error This file requires MRC
18+ #endif
19+
1620#import < sqlite3.h>
1721
1822#import " GCPrivate.h"
@@ -364,6 +368,7 @@ - (instancetype)initWithRepository:(GCRepository*)repository databasePath:(NSStr
364368 _options = options;
365369
366370 if (![self _initializeDatabase: path error: error]) {
371+ [self release ];
367372 return nil ;
368373 }
369374
@@ -372,27 +377,32 @@ - (instancetype)initWithRepository:(GCRepository*)repository databasePath:(NSStr
372377 NSInteger currentVersion = [self _readVersion ];
373378 if (currentVersion == version) {
374379 if (![self _checkReady: error]) {
380+ [self release ];
375381 return nil ;
376382 }
377383 } else {
378384 if (_options & kGCCommitDatabaseOptions_QueryOnly ) {
379385 GC_SET_GENERIC_ERROR (@" Database is query-only" );
386+ [self release ];
380387 return nil ;
381388 }
382389 sqlite3_close (_database);
383390 _database = NULL ;
384391 XLOG_WARNING (@" Commit database for \" %@ \" has an incompatible version (%li ) and must be regenerated" , _repository.repositoryPath , (long )currentVersion);
385392 if (![[NSFileManager defaultManager ] removeItemAtPath: path error: error] || ![self _initializeDatabase: path error: error] || ![self _initializeSchema: version error: error]) {
393+ [self release ];
386394 return nil ;
387395 }
388396 }
389397 } else {
390398 if (![self _initializeSchema: version error: error]) {
399+ [self release ];
391400 return nil ;
392401 }
393402 }
394403
395404 if (![self _initializeStatements: error]) {
405+ [self release ];
396406 return nil ;
397407 }
398408 }
@@ -407,6 +417,10 @@ - (void)dealloc {
407417 free (_statements);
408418 }
409419 sqlite3_close (_database);
420+
421+ [_databasePath release ];
422+
423+ [super dealloc ];
410424}
411425
412426#if DEBUG
@@ -889,6 +903,10 @@ - (BOOL)_addCommitsForTip:(const git_oid*)tipOID handler:(BOOL (^)())handler err
889903 success = YES ;
890904
891905cleanup:
906+ [deletedWords release ];
907+ [addedWords release ];
908+ [deletedLines release ];
909+ [addedLines release ];
892910 git_commit_free (mainParent);
893911 GC_LIST_FOR_LOOP_POINTER (newRow, itemPtr) {
894912 git_commit_free (itemPtr->commit );
@@ -1172,6 +1190,7 @@ - (NSArray*)findCommitsUsingHistory:(GCHistory*)history matching:(NSString*)matc
11721190 CHECK_LIBGIT2_FUNCTION_CALL (goto cleanup, status, == GIT_OK);
11731191 GCCommit* commit = [[GCCommit alloc ] initWithRepository: _repository commit: rawCommit];
11741192 [results addObject: commit];
1193+ [commit release ];
11751194 }
11761195 }
11771196 CALL_SQLITE_FUNCTION_GOTO (cleanup, sqlite3_reset, statements[kStatement_SearchCommits ]);
0 commit comments