diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-06-06 07:29:25 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-06-06 18:04:32 +0200 |
commit | b3e098d6e77db87946c50c3517fbdeffe9168ca9 (patch) | |
tree | c70c3a2c9564f68502c5e7a2308f50846f900279 /refs | |
parent | refs/files: extract function to iterate through root refs (diff) | |
download | git-b3e098d6e77db87946c50c3517fbdeffe9168ca9.tar.xz git-b3e098d6e77db87946c50c3517fbdeffe9168ca9.zip |
refs/files: fix NULL pointer deref when releasing ref store
The `free_ref_cache()` function is not `NULL` safe and will thus
segfault when being passed such a pointer. This can easily happen when
trying to release a partially initialized "files" ref store. Fix this.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r-- | refs/ref-cache.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/refs/ref-cache.c b/refs/ref-cache.c index b6c53fc8ed..4ce519bbc8 100644 --- a/refs/ref-cache.c +++ b/refs/ref-cache.c @@ -71,6 +71,8 @@ static void free_ref_entry(struct ref_entry *entry) void free_ref_cache(struct ref_cache *cache) { + if (!cache) + return; free_ref_entry(cache->root); free(cache); } |