Patch 8.2.5164
Problem:    Invalid memory access after diff buffer manipulations.
Solution:   Use zero offset when change removes all lines in a diff block.
Files:      src/diff.c, src/testdir/test_diffmode.vim


*** ../vim-8.2.5163/src/diff.c  2022-06-26 14:04:04.096859187 +0100
--- src/diff.c  2022-06-26 16:52:28.113205371 +0100
***************
*** 403,411 ****
                // 2. 3. 4. 5.: inserted/deleted lines touching this diff.
                if (deleted > 0)
                {
                    if (dp->df_lnum[idx] >= line1)
                    {
-                       off = dp->df_lnum[idx] - lnum_deleted;
                        if (last <= line2)
                        {
                            // 4. delete all lines of diff
--- 403,411 ----
                // 2. 3. 4. 5.: inserted/deleted lines touching this diff.
                if (deleted > 0)
                {
+                   off = 0;
                    if (dp->df_lnum[idx] >= line1)
                    {
                        if (last <= line2)
                        {
                            // 4. delete all lines of diff
***************
*** 426,431 ****
--- 426,432 ----
                        else
                        {
                            // 5. delete lines at or just before top of diff
+                           off = dp->df_lnum[idx] - lnum_deleted;
                            n = off;
                            dp->df_count[idx] -= line2 - dp->df_lnum[idx] + 1;
                            check_unchanged = TRUE;
***************
*** 434,440 ****
                    }
                    else
                    {
-                       off = 0;
                        if (last < line2)
                        {
                            // 2. delete at end of diff
--- 435,440 ----
*** ../vim-8.2.5163/src/testdir/test_diffmode.vim       2022-06-26 
14:04:04.096859187 +0100
--- src/testdir/test_diffmode.vim       2022-06-26 16:52:06.629198006 +0100
***************
*** 1615,1619 ****
--- 1615,1631 ----
    %bwipe!
  endfunc
  
+ " This was causing invalid diff block values
+ " FIXME: somehow this causes a valgrind error when run directly but not when
+ " run as a test.
+ func Test_diff_manipulations()
+   set diff
+   split 0
+   sil! norm R
 doo bdeu  R
 doo bdeu  R
 doo bdeu
+ 
+   set nodiff
+   %bwipe!
+ endfunc
+ 
  
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.5163/src/version.c       2022-06-26 14:04:04.096859187 +0100
--- src/version.c       2022-06-26 16:44:24.560990947 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     5164,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
7. You finally do take that vacation, but only after buying a USB modem
   and a laptop.

 /// 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/20220626155405.7C4EB1C480B%40moolenaar.net.

Raspunde prin e-mail lui