diff options
author | Sven Strickroth <email@cs-ware.de> | 2020-01-16 17:53:50 +0100 |
---|---|---|
committer | Sven Strickroth <email@cs-ware.de> | 2020-01-16 17:53:50 +0100 |
commit | 470a05d0d95ab8a840f1a851b1c498245ccfafaf (patch) | |
tree | 98445f1658707bad2108a42bda32f4ceb2743cf5 | |
parent | dea5ce3df6f62a490b3307edd06958eddc5e90f4 (diff) | |
download | libgit2-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.c | 3 | ||||
-rw-r--r-- | tests/repo/open.c | 2 |
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); |