diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-07-29 21:39:13 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-07-29 21:39:13 +0200 |
commit | c3d4c20c7d862fb168b4b2126443e13c55737507 (patch) | |
tree | 99156760fb563a9de7cc1a3c52581cb2a5acfa0a /xdiff | |
parent | Merge branch 'sg/travis-gcc-4.8' (diff) | |
parent | xdiff: clamp function context indices in post-image (diff) | |
download | git-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.c | 4 |
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; } |