Patch 8.2.4979

6 views
Skip to first unread message

Bram Moolenaar

unread,
May 18, 2022, 11:29:47 AM5/18/22
to vim...@googlegroups.com

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 -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages