1
0
mirror of https://github.com/git/git synced 2024-06-30 22:54:27 +00:00

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>
This commit is contained in:
Patrick Steinhardt 2024-06-06 07:29:25 +02:00 committed by Junio C Hamano
parent 120b67172f
commit b3e098d6e7

View File

@ -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);
}