mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.0101: invalid memory access in diff mode with "dp" and undo
Problem: Invalid memory access in diff mode with "dp" and undo. Solution: Make sure the line number does not go below one.
This commit is contained in:
@@ -464,7 +464,10 @@ diff_mark_adjust_tp(
|
|||||||
for (i = 0; i < DB_COUNT; ++i)
|
for (i = 0; i < DB_COUNT; ++i)
|
||||||
if (tp->tp_diffbuf[i] != NULL && i != idx)
|
if (tp->tp_diffbuf[i] != NULL && i != idx)
|
||||||
{
|
{
|
||||||
dp->df_lnum[i] -= off;
|
if (dp->df_lnum[i] > off)
|
||||||
|
dp->df_lnum[i] -= off;
|
||||||
|
else
|
||||||
|
dp->df_lnum[i] = 1;
|
||||||
dp->df_count[i] += n;
|
dp->df_count[i] += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2863,8 +2866,8 @@ ex_diffgetput(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
// remember deleting the last line of the buffer
|
// remember deleting the last line of the buffer
|
||||||
buf_empty = curbuf->b_ml.ml_line_count == 1;
|
buf_empty = curbuf->b_ml.ml_line_count == 1;
|
||||||
ml_delete(lnum);
|
if (ml_delete(lnum) == OK)
|
||||||
--added;
|
--added;
|
||||||
}
|
}
|
||||||
for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i)
|
for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i)
|
||||||
{
|
{
|
||||||
|
@@ -1628,5 +1628,19 @@ func Test_diff_manipulations()
|
|||||||
doobdeu
|
doobdeu
|
||||||
|
|
||||||
set nodiff
|
set nodiff
|
||||||
|
%bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" This was causing the line number in the diff block to go below one.
|
||||||
|
" FIXME: somehow this causes a valgrind error when run directly but not when
|
||||||
|
" run as a test.
|
||||||
|
func Test_diff_put_and_undo()
|
||||||
|
set diff
|
||||||
|
next 0
|
||||||
|
split 00
|
||||||
|
sil! norm o0gguudpo0ggJuudp
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
bwipe!
|
||||||
set nodiff
|
set nodiff
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -735,6 +735,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
101,
|
||||||
/**/
|
/**/
|
||||||
100,
|
100,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user