From: Ævar Arnfjörð Bjarmason Date: Fri, 05 Feb 2021 14:13:20 GMT Subject: [PATCH 2/2] diff: plug memory leak from regcomp() on {log,diff} -I Message-ID: <20210205141320.18076-2-avarab@gmail.com> In-Reply-To: <20201020064809.14297-1-michal@isc.org> Fix a memory leak in 296d4a94e7 (diff: add -I that ignores matching changes, 2020-10-20) by freeing the memory it allocates in the newly introduced diff_free(). See the previous commit for details on that. This memory leak was intentionally introduced in 296d4a94e7, see the discussion on a previous iteration of it in https://lore.kernel.org/git/xmqqeelycajx.fsf@gitster.c.googlers.com/ At that time freeing the memory was somewhat tedious, but since it isn't anymore with the newly introduced diff_free() let's use it. Signed-off-by: Ævar Arnfjörð Bjarmason --- diff.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/diff.c b/diff.c index 3e6f8f0a71..24257759bb 100644 --- a/diff.c +++ b/diff.c @@ -6450,10 +6450,17 @@ void diff_flush(struct diff_options *options) void diff_free(struct diff_options *options) { + int i; if (options->no_free) return; if (options->fclose_file) fclose(options->file); + + for (i = 0; i < options->ignore_regex_nr; i++) { + regfree(options->ignore_regex[i]); + free(options->ignore_regex[i]); + } + free(options->ignore_regex); } -- 2.30.0.284.gd98b1dd5eaa7