summaryrefslogtreecommitdiffstats
path: root/diff.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-08-14 08:52:55 +0200
committerJunio C Hamano <gitster@pobox.com>2024-08-14 19:08:01 +0200
commit36f971f86182a25fa2fa4af680bf79f522a27f60 (patch)
tree533e024f52ef2a51fcd94bcf5a1581f9ed8dcd9c /diff.c
parentbuiltin/log: fix leak when showing converted blob contents (diff)
downloadgit-36f971f86182a25fa2fa4af680bf79f522a27f60.tar.xz
git-36f971f86182a25fa2fa4af680bf79f522a27f60.zip
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c10
1 files changed, 10 insertions, 0 deletions
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);