mirror of
https://github.com/git/git.git
synced 2026-01-10 01:56:42 +00:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
43072b4ca1
commit
1a03591812
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user