path: root/xdiff
diff options
authorJohannes Schindelin <>2006-12-28 16:13:33 (GMT)
committerJunio C Hamano <>2006-12-28 21:59:39 (GMT)
commit5d6b151fdd0a9e41ba68b444760616da1a008433 (patch)
tree6e463b88e1adb37eb8248ce0ca179929a2ba7aa5 /xdiff
parent4a4d94b29b4546e15e6f25f8739663562d4f64a5 (diff)
xdl_merge(): fix a segmentation fault when refining conflicts
The function xdl_refine_conflicts() tries to break down huge conflicts by doing a diff on the conflicting regions. However, this does not make sense when one side is empty. Worse, when one side is not only empty, but after EOF, the code accessed unmapped memory. Noticed by Luben Tuikov, Shawn Pearce and Alexandre Julliard, the latter providing a test case. Signed-off-by: Johannes Schindelin <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'xdiff')
1 files changed, 4 insertions, 0 deletions
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 352207e..294450b 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -190,6 +190,10 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m,
if (m->mode)
+ /* no sense refining a conflict when one side is empty */
+ if (m->chg1 == 0 || m->chg2 == 0)
+ continue;
* This probably does not work outside git, since
* we have a very simple mmfile structure.