Commit 9d4c5505 by Carlos Martín Nieto

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.
parent 136e55f2
...@@ -153,7 +153,9 @@ int git_repository__cleanup(git_repository *repo) ...@@ -153,7 +153,9 @@ int git_repository__cleanup(git_repository *repo)
git_cache_clear(&repo->objects); git_cache_clear(&repo->objects);
git_attr_cache_flush(repo); git_attr_cache_flush(repo);
git_grafts_free(repo->grafts); git_grafts_free(repo->grafts);
repo->grafts = NULL;
git_grafts_free(repo->shallow_grafts); git_grafts_free(repo->shallow_grafts);
repo->shallow_grafts = NULL;
set_config(repo, NULL); set_config(repo, NULL);
set_index(repo, NULL); set_index(repo, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment