diff options
author | René Scharfe <l.s.r@web.de> | 2024-12-28 10:47:05 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-12-28 08:00:44 -0800 |
commit | 8db127d43f5b0eff254a851f9c966b7b85d91992 (patch) | |
tree | 8c7cd2c2a66573512ade8f4e80f5af8e88fe1e4b /builtin/commit-tree.c | |
parent | 76cf4f61c87855ebf0784b88aaf737d6b09f504b (diff) |
reftable: avoid leaks on realloc error
When realloc(3) fails, it returns NULL and keeps the original allocation
intact. REFTABLE_ALLOC_GROW overwrites both the original pointer and
the allocation count variable in that case, simultaneously leaking the
original allocation and misrepresenting the number of storable items.
parse_names() and reftable_buf_add() avoid leaking by restoring the
original pointer value on failure, but all other callers seem to be OK
with losing the old allocation. Add a new variant of the macro,
REFTABLE_ALLOC_GROW_OR_NULL, which plugs the leak and zeros the
allocation counter. Use it for those callers.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit-tree.c')
0 files changed, 0 insertions, 0 deletions