Skip to content

Commit a13d4a1

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

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

bisect.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ static int register_ref(const char *refname, const char *referent UNUSED, const
456456
strbuf_addstr(&good_prefix, "-");
457457

458458
if (!strcmp(refname, term_bad)) {
459+
free(current_bad_oid);
459460
current_bad_oid = xmalloc(sizeof(*current_bad_oid));
460461
oidcpy(current_bad_oid, oid);
461462
} else if (starts_with(refname, good_prefix.buf)) {

0 commit comments

Comments
 (0)