diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-05-27 13:46:54 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-05-27 11:20:01 -0700 |
commit | ba9d029445e183d7c7dda75887cee1b5d6fee1d7 (patch) | |
tree | 7909e0eedd9c7ca6d0ef60aa3d230cc3d47b530e /commit-reach.c | |
parent | 96c1655095ae21040afe9d9c05cf42bb0fc03581 (diff) |
commit-reach: fix memory leak in `ahead_behind()`
We use a priority queue in `ahead_behind()` to compute the ahead/behind
count for commits. We may not iterate through all commits part of that
queue though in case all of its entries are stale. Consequently, as we
never make the effort to release the remaining commits, we end up
leaking bit arrays that we have allocated for each of the contained
commits.
Plug this leak and mark the corresponding test as leak free.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-reach.c')
-rw-r--r-- | commit-reach.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/commit-reach.c b/commit-reach.c index 8f9b008f87..384aee1ab3 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -1106,6 +1106,10 @@ void ahead_behind(struct repository *r, /* STALE is used here, PARENT2 is used by insert_no_dup(). */ repo_clear_commit_marks(r, PARENT2 | STALE); + while (prio_queue_peek(&queue)) { + struct commit *c = prio_queue_get(&queue); + free_bit_array(c); + } clear_bit_arrays(&bit_arrays); clear_prio_queue(&queue); } |