Skip to content

Commit 1a03591

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 43072b4 commit 1a03591

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

reftable/record.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ static int reftable_obj_record_decode(void *rec, struct strbuf key,
569569
uint64_t last;
570570
int j;
571571

572+
reftable_obj_record_release(r);
573+
572574
REFTABLE_ALLOC_ARRAY(r->hash_prefix, key.len);
573575
memcpy(r->hash_prefix, key.buf, key.len);
574576
r->hash_prefix_len = key.len;

0 commit comments

Comments
 (0)