From: Patrick Steinhardt Date: Wed, 20 Nov 2024 13:39:32 +0000 (+0100) Subject: bisect: fix leaking string in `handle_bad_merge_base()` X-Git-Tag: v2.48.0-rc0~37^2~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=96ab0e7b8b586322c1da6bbcd40773a54472679b;p=thirdparty%2Fgit.git bisect: fix leaking string in `handle_bad_merge_base()` When handling a bad merge base we print an error, which includes the set of good revisions joined by spaces. This string is allocated, but never freed. Fix this memory leak. Note that the local `bad_hex` varible also looks like a string that we should free. But in fact, `oid_to_hex()` returns an address to a static variable even though it is declared to return a non-constant string. The function signature is thus quite misleading and really should be fixed, but doing so is outside of the scope of this patch series. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- diff --git a/bisect.c b/bisect.c index 9c52241050..e9e603877e 100644 --- a/bisect.c +++ b/bisect.c @@ -801,6 +801,8 @@ static enum bisect_error handle_bad_merge_base(void) "between %s and [%s].\n"), bad_hex, term_bad, term_good, bad_hex, good_hex); } + + free(good_hex); return BISECT_MERGE_BASE_CHECK; }