diff mbox series

format-patch: mark rev_info with UNLEAK

Message ID xmqqpmpw6s0p.fsf_-_@gitster.g (mailing list archive)
State Accepted
Commit dee839a26331a67f5018e10edb158bdb550d3a32
Headers show
Series format-patch: mark rev_info with UNLEAK | expand

Commit Message

Junio C Hamano Dec. 16, 2021, 11:37 p.m. UTC
The comand uses a single instance of rev_info on stack, makes a
single revision traversal and exit.  Mark the resources held by the
rev_info structure with UNLEAK().

We do not do this at lower level in revision.c or cmd_log_walk(), as
a new caller of the revision traversal API can make unbounded number
of rev_info during a single run, and UNLEAK() would not a be
suitable mechanism to deal with such a caller.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

    Junio C Hamano <gitster@pobox.com> writes:

    > Jerry Zhang <jerry@skydio.com> writes:
    >
    >>  t/t4126-apply-empty.sh      | 22 ++++++++++++++++++----
    >>  4 files changed, 30 insertions(+), 7 deletions(-)
    >> ...
    >> diff --git a/t/t4126-apply-empty.sh b/t/t4126-apply-empty.sh
    >> index ceb6a79fe0..949e284d14 100755
    >> --- a/t/t4126-apply-empty.sh
    >> +++ b/t/t4126-apply-empty.sh
    >> @@ -7,10 +7,12 @@ test_description='apply empty'
    >>  test_expect_success setup '
    >>  	>empty &&
    >>  	git add empty &&
    >>  	test_tick &&
    >>  	git commit -m initial &&
    >> +	git commit --allow-empty -m "empty commit" &&
    >> +	git format-patch --always HEAD~ >empty.patch &&
    >>  	for i in a b c d e
    >
    > When merged with anything that has ab/mark-leak-free-tests-even-more
    > topic, this will start breaking the tests, as it is my understanding
    > that "git log" family hasn't been audited and converted for leak
    > sanitizer.
    > ...
    > I am tempted to drop the "TEST_PASSES" bit from this script for now,
    > but I have to say that the "mark leak-free tests" topic took us in
    > an awkward place.  We probably want to do something a bit more fine
    > grained about it.

    Luckily, this test script is small enough that format-patch is the
    only new offender, it seems, and with the attached patch I plan to
    queue on a separate topic merged, it seem it no longer upsets the
    sanitizer.

 builtin/log.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/builtin/log.c b/builtin/log.c
index f75d87e8d7..a7bca8353b 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -2241,6 +2241,7 @@  int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	strbuf_release(&rdiff1);
 	strbuf_release(&rdiff2);
 	strbuf_release(&rdiff_title);
+	UNLEAK(rev);
 	return 0;
 }