From 3651c8870cc7c87aef2285d49d698164f488eac6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 24 Sep 2025 15:24:17 -0700 Subject: [PATCH] diff --no-index: fix logic for paths ending in '/' Junio C Hamano writes: > Hence, I think the clean-up code of this function this goto ... > >> goto out; > > ... jumps to would need > > strbuf_release(&ps_match1); > strbuf_release(&ps_match2); > > added after that "out:" label? > > If we run this test with leak sanitizer, wouldn't it find leak in > these (I haven't tried it myself---I just am speculating)? Now I did, and my speculations were both correct. The SANITIZE=leak build fails, and with these two releases the test passes. You can squash this in, or I can do so myself if you like, if this is the only change that is required. diff-no-index.c | 2 ++ 1 file changed, 2 insertions(+) Signed-off-by: Johannes Schindelin --- diff-no-index.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/diff-no-index.c b/diff-no-index.c index c70f82b805..f320424f05 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -436,6 +436,8 @@ out: for (i = 0; i < ARRAY_SIZE(to_free); i++) free(to_free[i]); strbuf_release(&replacement); + strbuf_release(&ps_match1); + strbuf_release(&ps_match2); if (ps) clear_pathspec(ps); return ret;