]> git.ipfire.org Git - thirdparty/git.git/commit
range-diff: don't segfault with mode-only changes
authorThomas Gummerer <t.gummerer@gmail.com>
Tue, 8 Oct 2019 17:38:43 +0000 (18:38 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Oct 2019 01:41:11 +0000 (10:41 +0900)
commit2b6a9b13ca4a687aeb0cad5f32e49711b3e67aaa
treebf3c67db6ca8048ab24be48ffaa4adf3868d566c
parent499352c2adf9c038ec3469d73590b1c55b6a343b
range-diff: don't segfault with mode-only changes

In ef283b3699 ("apply: make parse_git_diff_header public", 2019-07-11)
the 'parse_git_diff_header' function was made public and useable by
callers outside of apply.c.

However it was missed that its (then) only caller, 'find_header' did
some error handling, and completing 'struct patch' appropriately.

range-diff then started using this function, and tried to handle this
appropriately itself, but fell short in some cases.  This in turn
would lead to range-diff segfaulting when there are mode-only changes
in a range.

Move the error handling and completing of the struct into the
'parse_git_diff_header' function, so other callers can take advantage
of it.  This fixes the segfault in 'git range-diff'.

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
t/t3206-range-diff.sh
t/t3206/history.export