diff --git a/ObjectiveGit/GTRepository.m b/ObjectiveGit/GTRepository.m index cd4fce6b8..dde113c2c 100644 --- a/ObjectiveGit/GTRepository.m +++ b/ObjectiveGit/GTRepository.m @@ -407,6 +407,10 @@ - (BOOL)enumerateBranchesWithType:(GTBranchType)type error:(NSError **)error usi if (error) *error = [NSError git_errorFor:gitError description:@"Branch enumeration failed"]; return NO; } + + @onExit { + git_branch_iterator_free(iter); + }; git_branch_t branchType; while ((gitError = git_branch_next(&gitRef, &branchType, iter)) == GIT_OK) {