diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-11-20 14:39:33 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-11-21 00:23:41 +0100 |
commit | a13d4a19d2b260e27b262292f07f5f315f04e07d (patch) | |
tree | 044ee4ed6e829bca558433be078f5c203118dfe5 /bisect.c | |
parent | bisect: fix leaking string in `handle_bad_merge_base()` (diff) | |
download | git-a13d4a19d2b260e27b262292f07f5f315f04e07d.tar.xz git-a13d4a19d2b260e27b262292f07f5f315f04e07d.zip |
bisect: fix leaking `current_bad_oid`
When reading bisect refs we read the reference mapping to the "bad" term
into the global `current_bad_oid` variable. This is an allocated string,
but because it is global we never have to free it. This changes though
when `register_ref()` is being called multiple times, at which point
we'll overwrite the previous pointer and thus make it unreachable.
Fix this issue by freeing the previous value. This leak is exposed by
t6030, but plugging it does not make the whole test suite pass.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'bisect.c')
-rw-r--r-- | bisect.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -456,6 +456,7 @@ static int register_ref(const char *refname, const char *referent UNUSED, const strbuf_addstr(&good_prefix, "-"); if (!strcmp(refname, term_bad)) { + free(current_bad_oid); current_bad_oid = xmalloc(sizeof(*current_bad_oid)); oidcpy(current_bad_oid, oid); } else if (starts_with(refname, good_prefix.buf)) { |