summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Strickroth <email@cs-ware.de>2020-01-16 17:53:50 +0100
committerSven Strickroth <email@cs-ware.de>2020-01-16 17:53:50 +0100
commit470a05d0d95ab8a840f1a851b1c498245ccfafaf (patch)
tree98445f1658707bad2108a42bda32f4ceb2743cf5
parentdea5ce3df6f62a490b3307edd06958eddc5e90f4 (diff)
downloadlibgit2-470a05d0d95ab8a840f1a851b1c498245ccfafaf.tar.gz
Do not return free'd git_repository object on error
Regression introduced in commit dde6d9c706bf1ecab545da55ab874a016587af1f. This issue causes lots of crashes in TortoiseGit. Signed-off-by: Sven Strickroth <email@cs-ware.de>
-rw-r--r--src/repository.c3
-rw-r--r--tests/repo/open.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/repository.c b/src/repository.c
index 14968d75d..03f68201b 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -865,8 +865,7 @@ cleanup:
if (error < 0)
git_repository_free(repo);
-
- if (repo_ptr)
+ else if (repo_ptr)
*repo_ptr = repo;
return error;
diff --git a/tests/repo/open.c b/tests/repo/open.c
index 83b53c4b4..448ccdc87 100644
--- a/tests/repo/open.c
+++ b/tests/repo/open.c
@@ -277,7 +277,9 @@ void test_repo_open__bad_gitlinks(void)
for (scan = bad_links; *scan != NULL; scan++) {
make_gitlink_dir("alternate", *scan);
+ repo = NULL;
cl_git_fail(git_repository_open_ext(&repo, "alternate", 0, NULL));
+ cl_assert(repo == NULL);
}
git_futils_rmdir_r("invalid", NULL, GIT_RMDIR_REMOVE_FILES);