summaryrefslogtreecommitdiff
path: root/xdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-07-29 19:39:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-07-29 19:39:13 (GMT)
commitc3d4c20c7d862fb168b4b2126443e13c55737507 (patch)
tree99156760fb563a9de7cc1a3c52581cb2a5acfa0a /xdiff
parent995ec8a18f60c23b80ae7ed84f8c921652a6ebb3 (diff)
parentb777f3fd619ac2af507ffd3e7c5fe0d6e36e81f2 (diff)
downloadgit-c3d4c20c7d862fb168b4b2126443e13c55737507.zip
git-c3d4c20c7d862fb168b4b2126443e13c55737507.tar.gz
git-c3d4c20c7d862fb168b4b2126443e13c55737507.tar.bz2
Merge branch 'jk/xdiff-clamp-funcname-context-index'
The internal diff machinery can be made to read out of bounds while looking for --funcion-context line in a corner case, which has been corrected. * jk/xdiff-clamp-funcname-context-index: xdiff: clamp function context indices in post-image
Diffstat (limited to 'xdiff')
-rw-r--r--xdiff/xemit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 7778dc2..30713ae 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -210,7 +210,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
if (fs1 < 0)
fs1 = 0;
if (fs1 < s1) {
- s2 -= s1 - fs1;
+ s2 = XDL_MAX(s2 - (s1 - fs1), 0);
s1 = fs1;
}
}
@@ -232,7 +232,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
if (fe1 < 0)
fe1 = xe->xdf1.nrec;
if (fe1 > e1) {
- e2 += fe1 - e1;
+ e2 = XDL_MIN(e2 + (fe1 - e1), xe->xdf2.nrec);
e1 = fe1;
}