summaryrefslogtreecommitdiffstats
path: root/xdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-07-29 21:39:13 +0200
committerJunio C Hamano <gitster@pobox.com>2019-07-29 21:39:13 +0200
commitc3d4c20c7d862fb168b4b2126443e13c55737507 (patch)
tree99156760fb563a9de7cc1a3c52581cb2a5acfa0a /xdiff
parentMerge branch 'sg/travis-gcc-4.8' (diff)
parentxdiff: clamp function context indices in post-image (diff)
downloadgit-c3d4c20c7d862fb168b4b2126443e13c55737507.tar.xz
git-c3d4c20c7d862fb168b4b2126443e13c55737507.zip
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 7778dc2b19..30713ae9a9 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;
}