]> git.ipfire.org Git - thirdparty/git.git/commit
diff-lib: fix leaking diffopts in `do_diff_cache()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 5 Nov 2024 06:17:00 +0000 (07:17 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Nov 2024 06:37:52 +0000 (22:37 -0800)
commit8dd3cb4b45d06959f3344f02b2d45a4ccf8207d8
treef41ba7c0478f6829dc00b8135b7ffedfc3a109ea
parente29ff075e082ecdc6ee85baea83d32d4a055d186
diff-lib: fix leaking diffopts in `do_diff_cache()`

In `do_diff_cache()` we initialize a new `rev_info` and then overwrite
its `diffopt` with a user-provided set of options. This can leak memory
because `repo_init_revisions()` may end up allocating memory for the
`diffopt` itself depending on the configuration. And since that field is
overwritten we won't ever free it.

Plug the memory leak by releasing the diffopts before we overwrite them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib.c
t/t7610-mergetool.sh