Patch 9.0.1392
Problem:    Using NULL pointer with nested :open command.
Solution:   Check that ccline.cmdbuff is not NULL.
Files:      src/getchar.c, src/testdir/test_ex_mode.vim,
            src/testdir/term_util.vim


*** ../vim-9.0.1391/src/getchar.c       2023-02-20 18:44:29.594912053 +0000
--- src/getchar.c       2023-03-07 21:00:30.857831972 +0000
***************
*** 3107,3113 ****
      static int
  vgetorpeek(int advance)
  {
!     int               c, c1;
      int               timedout = FALSE;       // waited for more than 
'timeoutlen'
                                        // for mapping to complete or
                                        // 'ttimeoutlen' for complete key code
--- 3107,3113 ----
      static int
  vgetorpeek(int advance)
  {
!     int               c;
      int               timedout = FALSE;       // waited for more than 
'timeoutlen'
                                        // for mapping to complete or
                                        // 'ttimeoutlen' for complete key code
***************
*** 3474,3480 ****
                 * to the user with showcmd.
                 */
                showcmd_idx = 0;
!               c1 = 0;
                if (typebuf.tb_len > 0 && advance && !exmode_active)
                {
                    if (((State & (MODE_NORMAL | MODE_INSERT))
--- 3474,3480 ----
                 * to the user with showcmd.
                 */
                showcmd_idx = 0;
!               int showing_partial = FALSE;
                if (typebuf.tb_len > 0 && advance && !exmode_active)
                {
                    if (((State & (MODE_NORMAL | MODE_INSERT))
***************
*** 3489,3495 ****
                            edit_putchar(typebuf.tb_buf[typebuf.tb_off
                                                + typebuf.tb_len - 1], FALSE);
                            setcursor(); // put cursor back where it belongs
!                           c1 = 1;
                        }
                        // need to use the col and row from above here
                        old_wcol = curwin->w_wcol;
--- 3489,3495 ----
                            edit_putchar(typebuf.tb_buf[typebuf.tb_off
                                                + typebuf.tb_len - 1], FALSE);
                            setcursor(); // put cursor back where it belongs
!                           showing_partial = TRUE;
                        }
                        // need to use the col and row from above here
                        old_wcol = curwin->w_wcol;
***************
*** 3506,3513 ****
                        curwin->w_wrow = old_wrow;
                    }
  
!                   // this looks nice when typing a dead character map
                    if ((State & MODE_CMDLINE)
  #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
                            && cmdline_star == 0
  #endif
--- 3506,3515 ----
                        curwin->w_wrow = old_wrow;
                    }
  
!                   // This looks nice when typing a dead character map.
!                   // There is no actual command line for get_number().
                    if ((State & MODE_CMDLINE)
+                           && get_cmdline_info()->cmdbuff != NULL
  #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
                            && cmdline_star == 0
  #endif
***************
*** 3516,3522 ****
                    {
                        putcmdline(typebuf.tb_buf[typebuf.tb_off
                                                + typebuf.tb_len - 1], FALSE);
!                       c1 = 1;
                    }
                }
  
--- 3518,3524 ----
                    {
                        putcmdline(typebuf.tb_buf[typebuf.tb_off
                                                + typebuf.tb_len - 1], FALSE);
!                       showing_partial = TRUE;
                    }
                }
  
***************
*** 3550,3560 ****
  
                if (showcmd_idx != 0)
                    pop_showcmd();
!               if (c1 == 1)
                {
                    if (State & MODE_INSERT)
                        edit_unputchar();
!                   if (State & MODE_CMDLINE)
                        unputcmdline();
                    else
                        setcursor();    // put cursor back where it belongs
--- 3552,3563 ----
  
                if (showcmd_idx != 0)
                    pop_showcmd();
!               if (showing_partial)
                {
                    if (State & MODE_INSERT)
                        edit_unputchar();
!                   if ((State & MODE_CMDLINE)
!                                       && get_cmdline_info()->cmdbuff != NULL)
                        unputcmdline();
                    else
                        setcursor();    // put cursor back where it belongs
*** ../vim-9.0.1391/src/testdir/test_ex_mode.vim        2022-09-21 
21:59:58.273433517 +0100
--- src/testdir/test_ex_mode.vim        2023-03-07 20:38:42.134582897 +0000
***************
*** 134,139 ****
--- 134,161 ----
    bwipe!
  endfunc
  
+ " FIXME: this doesn't fail without the fix but hangs
+ func Skip_Test_open_command_state()
+   " Tricky script that failed because State was not set properly
+   let lines =<< trim END
+       !ls ƒ
+       0scìi
+       so! Xsourced
+       set t_û0=0
+       v/-/o
+   END
+   call writefile(lines, 'XopenScript', '')
+ 
+   let sourced = ["!f\u0083\x02\<Esc>z=0"]
+   call writefile(sourced, 'Xsourced', 'b')
+ 
+   CheckRunVimInTerminal
+   let buf = RunVimInTerminal('-u NONE -i NONE -n -m -X -Z -e -s -S 
XopenScript -c qa!', #{rows: 6, wait_for_ruler: 0, no_clean: 1})
+   sleep 3
+ 
+   call StopVimInTerminal(buf)
+ endfunc
+ 
  " Test for :g/pat/visual to run vi commands in Ex mode
  " This used to hang Vim before 8.2.0274.
  func Test_Ex_global()
*** ../vim-9.0.1391/src/testdir/term_util.vim   2022-12-31 11:44:51.545772459 
+0000
--- src/testdir/term_util.vim   2023-03-07 20:35:11.186761760 +0000
***************
*** 55,60 ****
--- 55,61 ----
  " "cols" - width of the terminal window (max. 78)
  " "statusoff" - number of lines the status is offset from default
  " "wait_for_ruler" - if zero then don't wait for ruler to show
+ " "no_clean" - if non-zero then remove "--clean" from the command
  func RunVimInTerminal(arguments, options)
    " If Vim doesn't exit a swap file remains, causing other tests to fail.
    " Remove it here.
***************
*** 91,96 ****
--- 92,101 ----
  
    let cmd = GetVimCommandCleanTerm() .. reset_u7 .. a:arguments
  
+   if get(a:options, 'no_clean', 0)
+     let cmd = substitute(cmd, '--clean', '', '')
+   endif
+ 
    let options = #{curwin: 1}
    if &termwinsize == ''
      let options.term_rows = rows
*** ../vim-9.0.1391/src/version.c       2023-03-07 17:45:07.192247897 +0000
--- src/version.c       2023-03-07 19:43:25.493807107 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1392,
  /**/

-- 
Eagles may soar, but weasels don't get sucked into jet engines.

 /// 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/20230307210533.4B8821C1280%40moolenaar.net.

Raspunde prin e-mail lui