Skip to content

Commit 470a05d

Browse files
committed
Do not return free'd git_repository object on error
Regression introduced in commit dde6d9c. This issue causes lots of crashes in TortoiseGit. Signed-off-by: Sven Strickroth <email@cs-ware.de>
1 parent dea5ce3 commit 470a05d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/repository.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,7 @@ int git_repository_open_ext(
865865

866866
if (error < 0)
867867
git_repository_free(repo);
868-
869-
if (repo_ptr)
868+
else if (repo_ptr)
870869
*repo_ptr = repo;
871870

872871
return error;

tests/repo/open.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ void test_repo_open__bad_gitlinks(void)
277277

278278
for (scan = bad_links; *scan != NULL; scan++) {
279279
make_gitlink_dir("alternate", *scan);
280+
repo = NULL;
280281
cl_git_fail(git_repository_open_ext(&repo, "alternate", 0, NULL));
282+
cl_assert(repo == NULL);
281283
}
282284

283285
git_futils_rmdir_r("invalid", NULL, GIT_RMDIR_REMOVE_FILES);

0 commit comments

Comments
 (0)