diff options
author | Matheus Tavares <matheus.bernardino@usp.br> | 2020-09-28 21:01:53 -0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-09-28 17:41:53 -0700 |
commit | bda959c4766d73ab435f26f2cc7c8c67b9443f5a (patch) | |
tree | d7ddc14cf2d77d2a9a467ce6e2c83dece7618fcb /t/helper/test-repository.c | |
parent | packfile: fix race condition on unpack_entry() (diff) | |
download | tgif-bda959c4766d73ab435f26f2cc7c8c67b9443f5a.tar.xz |
packfile: fix memory leak in add_delta_base_cache()
When add_delta_base_cache() is called with a base that is already in the
cache, no operation is performed. But the check is done after allocating
space for a new entry, so we end up leaking memory on the early return.
In addition, the caller never free()'s the base as it expects the
function to take ownership of it. But the base is not released when we
skip insertion, so it also gets leaked. To fix these problems, move the
allocation of a new entry further down in add_delta_base_cache(), and
free() the base on early return.
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper/test-repository.c')
0 files changed, 0 insertions, 0 deletions