Skip to content

Commit 86a4a26

Browse files
carlosmnethomson
authored andcommitted
repository: make cleanup safe for re-use with grafts
We are allowed to call `git_repository__cleanup` multiple times, and this happens e.g. in rugged if we want to free up resources before GC gets around to them. This means that we cannot leave dangling pointers in it, which we were doing with the grafts. Fix this by setting the pointers to NULL after freeing the resources.
1 parent 085a169 commit 86a4a26

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libgit2/repository.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ int git_repository__cleanup(git_repository *repo)
153153
git_cache_clear(&repo->objects);
154154
git_attr_cache_flush(repo);
155155
git_grafts_free(repo->grafts);
156+
repo->grafts = NULL;
156157
git_grafts_free(repo->shallow_grafts);
158+
repo->shallow_grafts = NULL;
157159

158160
set_config(repo, NULL);
159161
set_index(repo, NULL);

0 commit comments

Comments
 (0)