Patch 8.2.2122
Problem:    Vim9: crash when sourcing vim9script early.
Solution:   Use set_option_value() instead of setting p_cpo directly.
            (closes #7441)
Files:      src/scriptfile.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.2121/src/scriptfile.c    2020-11-12 20:16:35.699302831 +0100
--- src/scriptfile.c    2020-12-09 17:12:58.213078449 +0100
***************
*** 1491,1498 ****
      si = SCRIPT_ITEM(current_sctx.sc_sid);
      if (si->sn_save_cpo != NULL)
      {
!       free_string_option(p_cpo);
!       p_cpo = si->sn_save_cpo;
        si->sn_save_cpo = NULL;
      }
  
--- 1491,1497 ----
      si = SCRIPT_ITEM(current_sctx.sc_sid);
      if (si->sn_save_cpo != NULL)
      {
!       set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0);
        si->sn_save_cpo = NULL;
      }
  
*** ../vim-8.2.2121/src/testdir/test_vim9_script.vim    2020-12-06 
14:37:04.717124932 +0100
--- src/testdir/test_vim9_script.vim    2020-12-09 17:14:49.592791281 +0100
***************
*** 2857,2862 ****
--- 2857,2873 ----
    delete('Xdidit')
  enddef
  
+ def Test_restoring_cpo()
+   writefile(['vim9script', 'set nocp'], 'Xsourced')
+   writefile(['call writefile(["done"], "Xdone")', 'quit!'], 'Xclose')
+   if RunVim([], [], '-u NONE +"set cpo+=a" -S Xsourced -S Xclose')
+     assert_equal(['done'], readfile('Xdone'))
+   endif
+   delete('Xsourced')
+   delete('Xclose')
+ enddef
+ 
+ 
  def Test_unset_any_variable()
    var lines =<< trim END
      var name: any
*** ../vim-8.2.2121/src/version.c       2020-12-09 16:36:00.404656177 +0100
--- src/version.c       2020-12-09 17:07:40.749843775 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2122,
  /**/

-- 
A special cleaning ordinance bans housewives from hiding dirt and dust under a
rug in a dwelling.
                [real standing law in Pennsylvania, United States of America]

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202012091617.0B9GHNqn1956356%40masaka.moolenaar.net.

Raspunde prin e-mail lui