[PATCH 0/4] reftable: fix realloc error handling
- From
René Scharfe <l.s.r@web.de>
- Date
- Dec 25, 2024, 18:33 UTC
- Message-ID
- <2b9fba8d-be63-4145-9d25-a2151e422cfa@web.de>
The current handling of reallocation errors leaks the original allocation in most cases and corrupts the capacity variable. Fix that in REFTABLE_ALLOC_GROW and by providing a new macro REFTABLE_ALLOC_GROW_OR_NULL -- solve this somewhat tricky issue centrally, with minimal impact to calling code.
And the last two patches add error handling to the remaining places that still lack it.
reftable: avoid leaks on realloc error reftable: fix allocation count on realloc error reftable: handle realloc error in parse_names() t-reftable-merged: handle realloc errors
reftable/basics.c | 14 ++++------- reftable/basics.h | 41 +++++++++++++++++++++++++------- reftable/block.c | 10 ++++---- reftable/pq.c | 2 +- reftable/record.c | 12 +++++----- reftable/stack.c | 8 ++++--- reftable/writer.c | 5 ++-- t/unit-tests/t-reftable-merged.c | 4 ++-- 8 files changed, 60 insertions(+), 36 deletions(-)
-- 2.47.1