Patch 8.2.1959
Problem:    Crash when terminal buffer name is made empty. (Dhiraj Mishra)
Solution:   Fall back to "[No Name]". (closes #7262)
Files:      src/buffer.c, src/proto/buffer.pro, src/terminal.c,
            src/testdir/test_terminal.vim


*** ../vim-8.2.1958/src/buffer.c        2020-10-28 20:19:56.368057090 +0100
--- src/buffer.c        2020-11-05 19:20:24.797053973 +0100
***************
*** 5648,5658 ****
      }
  
      if (buf->b_fname == NULL)
!       return (char_u *)_("[No Name]");
      return NULL;
  }
  
  /*
   * Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed.
   */
      void
--- 5648,5669 ----
      }
  
      if (buf->b_fname == NULL)
!       return buf_get_fname(buf);
      return NULL;
  }
  
  /*
+  * Get "buf->b_fname", use "[No Name]" if it is NULL.
+  */
+     char_u *
+ buf_get_fname(buf_T *buf)
+ {
+     if (buf->b_fname == NULL)
+       return (char_u *)_("[No Name]");
+     return buf->b_fname;
+ }
+ 
+ /*
   * Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed.
   */
      void
*** ../vim-8.2.1958/src/proto/buffer.pro        2020-10-26 21:05:23.905469139 
+0100
--- src/proto/buffer.pro        2020-11-05 19:21:47.432811161 +0100
***************
*** 66,71 ****
--- 66,72 ----
  int bt_dontwrite_msg(buf_T *buf);
  int buf_hide(buf_T *buf);
  char_u *buf_spname(buf_T *buf);
+ char_u *buf_get_fname(buf_T *buf);
  void set_buflisted(int on);
  int buf_contents_changed(buf_T *buf);
  void wipe_buffer(buf_T *buf, int aucmd);
*** ../vim-8.2.1958/src/terminal.c      2020-10-24 20:49:37.502683026 +0200
--- src/terminal.c      2020-11-05 19:29:17.435528257 +0100
***************
*** 1598,1604 ****
        char_u  buff[DIALOG_MSG_SIZE];
        int     ret;
  
!       dialog_msg(buff, _("Kill job in \"%s\"?"), buf->b_fname);
        ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
        if (ret == VIM_YES)
            how = "kill";
--- 1598,1604 ----
        char_u  buff[DIALOG_MSG_SIZE];
        int     ret;
  
!       dialog_msg(buff, _("Kill job in \"%s\"?"), buf_get_fname(buf));
        ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
        if (ret == VIM_YES)
            how = "kill";
***************
*** 4517,4522 ****
--- 4517,4523 ----
      {
        char_u *txt;
        size_t len;
+       char_u *fname;
  
        if (term->tl_normal_mode)
        {
***************
*** 4533,4543 ****
            txt = (char_u *)_("running");
        else
            txt = (char_u *)_("finished");
!       len = 9 + STRLEN(term->tl_buffer->b_fname) + STRLEN(txt);
        term->tl_status_text = alloc(len);
        if (term->tl_status_text != NULL)
            vim_snprintf((char *)term->tl_status_text, len, "%s [%s]",
!                                               term->tl_buffer->b_fname, txt);
      }
      return term->tl_status_text;
  }
--- 4534,4545 ----
            txt = (char_u *)_("running");
        else
            txt = (char_u *)_("finished");
!       fname = buf_get_fname(term->tl_buffer);
!       len = 9 + STRLEN(fname) + STRLEN(txt);
        term->tl_status_text = alloc(len);
        if (term->tl_status_text != NULL)
            vim_snprintf((char *)term->tl_status_text, len, "%s [%s]",
!                                                                  fname, txt);
      }
      return term->tl_status_text;
  }
*** ../vim-8.2.1958/src/testdir/test_terminal.vim       2020-11-01 
20:58:22.835423347 +0100
--- src/testdir/test_terminal.vim       2020-11-05 19:28:07.339724836 +0100
***************
*** 41,46 ****
--- 41,56 ----
    unlet g:job
  endfunc
  
+ func Test_terminal_no_name()
+   let buf = Run_shell_in_terminal({})
+   call assert_match('^!', bufname(buf))
+   0file
+   call assert_equal("", bufname(buf))
+   call assert_match('\[No Name\]', execute('file'))
+   call StopShellInTerminal(buf)
+   call TermWait(buf)
+ endfunc
+ 
  func Test_terminal_TerminalWinOpen()
    au TerminalWinOpen * let b:done = 'yes'
    let buf = Run_shell_in_terminal({})
*** ../vim-8.2.1958/src/version.c       2020-11-05 19:34:37.774638811 +0100
--- src/version.c       2020-11-05 19:36:14.146373511 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1959,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
199. You read this entire list of symptoms, looking for something
     that doesn't describe you.

 /// 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/202011051902.0A5J2QAC212587%40masaka.moolenaar.net.

Raspunde prin e-mail lui