Patch 8.2.4979
Problem:    Accessing freed memory when line is flushed.
Solution:   Make a copy of the pattern to search for.
Files:      src/window.c, src/testdir/test_tagjump.vim


*** ../vim-8.2.4978/src/window.c        2022-05-09 20:09:19.298641424 +0100
--- src/window.c        2022-05-18 16:28:19.833715609 +0100
***************
*** 579,587 ****
--- 579,594 ----
                CHECK_CMDWIN;
                if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0)
                    break;
+ 
+               // Make a copy, if the line was changed it will be freed.
+               ptr = vim_strnsave(ptr, len);
+               if (ptr == NULL)
+                   break;
+ 
                find_pattern_in_path(ptr, 0, len, TRUE,
                        Prenum == 0 ? TRUE : FALSE, type,
                        Prenum1, ACTION_SPLIT, (linenr_T)1, (linenr_T)MAXLNUM);
+               vim_free(ptr);
                curwin->w_set_curswant = TRUE;
                break;
  #endif
*** ../vim-8.2.4978/src/testdir/test_tagjump.vim        2022-03-11 
12:05:15.495608365 +0000
--- src/testdir/test_tagjump.vim        2022-05-18 16:20:52.050537374 +0100
***************
*** 1392,1397 ****
--- 1392,1406 ----
    close!
  endfunc
  
+ func Test_define_search()
+   " this was accessing freed memory
+   new
+   call setline(1, ['first line', '', '#define something 0'])
+   sil norm o0
+   sil! norm   
+   bwipe!
+ endfunc
+ 
  " Test for [*, [/, ]* and ]/
  func Test_comment_search()
    new
*** ../vim-8.2.4978/src/version.c       2022-05-18 15:03:58.171540249 +0100
--- src/version.c       2022-05-18 16:21:54.618417907 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4979,
  /**/

-- 
Get a life?  What is the URL where it can be downloaded?

 /// 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/20220518152943.1654B1C0AE8%40moolenaar.net.

Raspunde prin e-mail lui