From 36f971f86182a25fa2fa4af680bf79f522a27f60 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 14 Aug 2024 08:52:55 +0200 Subject: diff: free state populated via options The `objfind` and `anchors` members of `struct diff_options` are populated via option parsing, but are never freed in `diff_free()`. Fix this to plug those memory leaks. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- diff.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 9251c47b72..4035a9374d 100644 --- a/diff.c +++ b/diff.c @@ -6717,6 +6717,16 @@ void diff_free(struct diff_options *options) if (options->no_free) return; + if (options->objfind) { + oidset_clear(options->objfind); + FREE_AND_NULL(options->objfind); + } + + for (size_t i = 0; i < options->anchors_nr; i++) + free(options->anchors[i]); + FREE_AND_NULL(options->anchors); + options->anchors_nr = options->anchors_alloc = 0; + diff_free_file(options); diff_free_ignore_regex(options); clear_pathspec(&options->pathspec); -- cgit 1.2.3-korg