diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-03-07 21:35:58 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-07 13:59:19 -0800 |
commit | 1a0359181263029468736aba04565af308be89d0 (patch) | |
tree | ced38c3b52d618cd0f6762333fd42279dfd5c7db /reftable | |
parent | 43072b4ca132437f21975ac6acc6b72dc22fd398 (diff) | |
download | git-1a0359181263029468736aba04565af308be89d0.tar.gz |
reftable/record: fix memory leak when decoding object records
When decoding records it is customary to reuse a `struct
reftable_ref_record` across calls. Thus, it may happen that the record
already holds some allocated memory. When decoding ref and log records
we handle this by releasing or reallocating held memory. But we fail to
do this for object records, which causes us to leak memory.
Fix this memory leak by releasing object records before we decode into
them. We may eventually want to reuse memory instead to avoid needless
reallocations. But for now, let's just plug the leak and be done.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable')
-rw-r--r-- | reftable/record.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/reftable/record.c b/reftable/record.c index d6bb42e887..9c31feb35c 100644 --- a/reftable/record.c +++ b/reftable/record.c @@ -569,6 +569,8 @@ static int reftable_obj_record_decode(void *rec, struct strbuf key, uint64_t last; int j; + reftable_obj_record_release(r); + REFTABLE_ALLOC_ARRAY(r->hash_prefix, key.len); memcpy(r->hash_prefix, key.buf, key.len); r->hash_prefix_len = key.len; |