Patch 9.0.0530
Problem:    Using freed memory when autocmd changes mark.
Solution:   Copy the mark before editing another buffer.
Files:      src/mark.c, src/testdir/test_marks.vim


*** ../vim-9.0.0529/src/mark.c  2022-06-16 11:32:39.000000000 +0100
--- src/mark.c  2022-09-21 13:05:15.908543070 +0100
***************
*** 221,237 ****
            fname2fnum(jmp);
        if (jmp->fmark.fnum != curbuf->b_fnum)
        {
!           // jump to other file
!           if (buflist_findnr(jmp->fmark.fnum) == NULL)
            {                                        // Skip this one ..
                count += count < 0 ? -1 : 1;
                continue;
            }
!           if (buflist_getfile(jmp->fmark.fnum, jmp->fmark.mark.lnum,
!                                                           0, FALSE) == FAIL)
                return (pos_T *)NULL;
            // Set lnum again, autocommands my have changed it
!           curwin->w_cursor = jmp->fmark.mark;
            pos = (pos_T *)-1;
        }
        else
--- 221,239 ----
            fname2fnum(jmp);
        if (jmp->fmark.fnum != curbuf->b_fnum)
        {
!           // Make a copy, an autocommand may make "jmp" invalid.
!           fmark_T fmark = jmp->fmark;
! 
!           // jump to the file with the mark
!           if (buflist_findnr(fmark.fnum) == NULL)
            {                                        // Skip this one ..
                count += count < 0 ? -1 : 1;
                continue;
            }
!           if (buflist_getfile(fmark.fnum, fmark.mark.lnum, 0, FALSE) == FAIL)
                return (pos_T *)NULL;
            // Set lnum again, autocommands my have changed it
!           curwin->w_cursor = fmark.mark;
            pos = (pos_T *)-1;
        }
        else
*** ../vim-9.0.0529/src/testdir/test_marks.vim  2021-10-17 21:46:49.000000000 
+0100
--- src/testdir/test_marks.vim  2022-09-21 13:01:53.158220086 +0100
***************
*** 305,308 ****
--- 305,321 ----
    close!
  endfunc
  
+ " This was using freed memory
+ func Test_jump_mark_autocmd()
+   next 00
+   edit 0
+   sargument
+   au BufEnter 0 all
+   sil norm   
+ 
+   au! BufEnter
+   bwipe!
+ endfunc
+ 
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.0529/src/version.c       2022-09-21 12:19:41.612159067 +0100
--- src/version.c       2022-09-21 13:03:06.423194363 +0100
***************
*** 701,702 ****
--- 701,704 ----
  {   /* Add new patch number below this line */
+ /**/
+     530,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
121. You ask for e-mail adresses instead of telephone numbers.

 /// 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/20220921120749.5E4091C0642%40moolenaar.net.

Raspunde prin e-mail lui