apply: plug a leak in apply_data
commit71c791605365d1873ef631bfc478fcd75080a063
authorRubén Justo <rjusto@gmail.com>
Mon, 22 Apr 2024 22:54:05 +0000 (23 00:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Apr 2024 23:27:42 +0000 (22 16:27 -0700)
treec09e487dc6fac2fab51dee9d08ef335684c7f7c0
parentae3196a5ea84a9e88991d576020cf66512487088
apply: plug a leak in apply_data

We have an execution path in apply_data that leaks the local struct
image.  Plug it.

This leak can be triggered with:

    $ echo foo >file
    $ git add file && git commit -m file
    $ echo bar >file
    $ git diff file >diff
    $ sed s/foo/frotz/ <diff >baddiff
    $ git apply --cached <baddiff

Fixing this leak allows us to mark as leak-free the following tests:

    + t2016-checkout-patch.sh
    + t4103-apply-binary.sh
    + t4104-apply-boundary.sh
    + t4113-apply-ending.sh
    + t4117-apply-reject.sh
    + t4123-apply-shrink.sh
    + t4252-am-options.sh
    + t4258-am-quoted-cr.sh

Mark them with "TEST_PASSES_SANITIZE_LEAK=true" to notice and fix
promply any new leak that may be introduced and triggered by them in the
future.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
t/t2016-checkout-patch.sh
t/t4103-apply-binary.sh
t/t4104-apply-boundary.sh
t/t4113-apply-ending.sh
t/t4117-apply-reject.sh
t/t4123-apply-shrink.sh
t/t4252-am-options.sh
t/t4258-am-quoted-cr.sh