Patch 8.2.5024
Problem:    Using freed memory with "]d".
Solution:   Copy the pattern before searching.
Files:      src/normal.c, src/testdir/test_tagjump.vim


*** ../vim-8.2.5023/src/normal.c        2022-05-26 15:56:18.069351933 +0100
--- src/normal.c        2022-05-26 16:29:44.708375062 +0100
***************
*** 4464,4469 ****
--- 4464,4474 ----
            clearop(cap->oap);
        else
        {
+           // Make a copy, if the line was changed it will be freed.
+           ptr = vim_strnsave(ptr, len);
+           if (ptr == NULL)
+               return;
+ 
            find_pattern_in_path(ptr, 0, len, TRUE,
                cap->count0 == 0 ? !isupper(cap->nchar) : FALSE,
                ((cap->nchar & 0xf) == ('d' & 0xf)) ?  FIND_DEFINE : FIND_ANY,
***************
*** 4472,4477 ****
--- 4477,4483 ----
                            islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO,
                cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1,
                (linenr_T)MAXLNUM);
+           vim_free(ptr);
            curwin->w_set_curswant = TRUE;
        }
      }
*** ../vim-8.2.5023/src/testdir/test_tagjump.vim        2022-05-18 
16:29:04.345637132 +0100
--- src/testdir/test_tagjump.vim        2022-05-26 16:24:35.580570656 +0100
***************
*** 1399,1404 ****
--- 1399,1410 ----
    sil norm o0
    sil! norm   
    bwipe!
+ 
+   new somefile
+   call setline(1, ['first line', '', '#define something 0'])
+   sil norm 0o0
+   sil! norm ]d
+   bwipe!
  endfunc
  
  " Test for [*, [/, ]* and ]/
*** ../vim-8.2.5023/src/version.c       2022-05-26 15:56:18.073351934 +0100
--- src/version.c       2022-05-26 16:31:32.884224729 +0100
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     5024,
  /**/

-- 
You were lucky. We lived for three months in a brown paper bag in a 
septic tank. We used to have to get up at six o'clock in the morning, 
clean the bag, eat a crust of stale bread, go to work down mill for 
fourteen hours a day week in-week out. When we got home, our Dad
would thrash us to sleep with his belt!

 /// 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/20220526153318.EF2661C0B4C%40moolenaar.net.

Raspunde prin e-mail lui