Patch 9.0.0101
Problem: Invalid memory access in diff mode with "dp" and undo.
Solution: Make sure the line number does not go below one.
Files: src/diff.c, src/testdir/test_diffmode.vim
*** ../vim-9.0.0100/src/diff.c 2022-07-02 15:09:56.866464463 +0100
--- src/diff.c 2022-07-28 18:43:29.277959224 +0100
***************
*** 464,470 ****
for (i = 0; i < DB_COUNT; ++i)
if (tp->tp_diffbuf[i] != NULL && i != idx)
{
! dp->df_lnum[i] -= off;
dp->df_count[i] += n;
}
}
--- 464,473 ----
for (i = 0; i < DB_COUNT; ++i)
if (tp->tp_diffbuf[i] != NULL && i != idx)
{
! if (dp->df_lnum[i] > off)
! dp->df_lnum[i] -= off;
! else
! dp->df_lnum[i] = 1;
dp->df_count[i] += n;
}
}
***************
*** 2863,2870 ****
{
// remember deleting the last line of the buffer
buf_empty = curbuf->b_ml.ml_line_count == 1;
! ml_delete(lnum);
! --added;
}
for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i)
{
--- 2866,2873 ----
{
// remember deleting the last line of the buffer
buf_empty = curbuf->b_ml.ml_line_count == 1;
! if (ml_delete(lnum) == OK)
! --added;
}
for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i)
{
*** ../vim-9.0.0100/src/testdir/test_diffmode.vim 2022-06-26
18:16:28.000000000 +0100
--- src/testdir/test_diffmode.vim 2022-07-28 18:43:20.717972483 +0100
***************
*** 1628,1632 ****
--- 1628,1646 ----
%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 o0 gguudpo0 ggJuudp
+
+ bwipe!
+ bwipe!
+ set nodiff
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.0100/src/version.c 2022-07-28 12:54:04.966094313 +0100
--- src/version.c 2022-07-28 18:35:58.094592970 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 101,
/**/
--
Living in Hollywood is like living in a bowl of granola. What ain't
fruits and nuts is flakes.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220728180632.72ED71C09F2%40moolenaar.net.