Patch 9.0.1270
Problem:    Crash when using search stat in narrow screen.
Solution:   Check length of message. (closes #11921)
Files:      src/search.c, src/testdir/test_search_stat.vim


*** ../vim-9.0.1269/src/search.c        2023-01-23 20:46:16.162493149 +0000
--- src/search.c        2023-01-31 21:12:27.606121776 +0000
***************
*** 3154,3160 ****
        len += 2;
      }
  
!     mch_memmove(msgbuf + STRLEN(msgbuf) - len, t, len);
      if (dirc == '?' && stat.cur == maxcount + 1)
        stat.cur = -1;
  
--- 3154,3164 ----
        len += 2;
      }
  
!     size_t msgbuf_len = STRLEN(msgbuf);
!     if (len > msgbuf_len)
!       len = msgbuf_len;
!     mch_memmove(msgbuf + msgbuf_len - len, t, len);
! 
      if (dirc == '?' && stat.cur == maxcount + 1)
        stat.cur = -1;
  
*** ../vim-9.0.1269/src/testdir/test_search_stat.vim    2022-10-10 
22:39:38.203545897 +0100
--- src/testdir/test_search_stat.vim    2023-01-31 21:11:23.178131901 +0000
***************
*** 270,275 ****
--- 270,298 ----
    call assert_fails('echo searchcount({"pos" : [1, 2, []]})', 'E745:')
  endfunc
  
+ func Test_search_stat_narrow_screen()
+   " This used to crash Vim
+   let save_columns = &columns
+   try
+     let after =<< trim [CODE]
+       set laststatus=2
+       set columns=16
+       set shortmess-=S showcmd
+       call setline(1, 'abc')
+       call feedkeys("/abc\<CR>:quit!\<CR>")
+       autocmd VimLeavePre * call writefile(["done"], "Xdone")
+     [CODE]
+ 
+     if !RunVim([], after, '--clean')
+       return
+     endif
+     call assert_equal("done", readfile("Xdone")[0])
+     call delete('Xdone')
+   finally
+     let &columns = save_columns
+   endtry
+ endfunc
+ 
  func Test_searchcount_in_statusline()
    CheckScreendump
  
*** ../vim-9.0.1269/src/version.c       2023-01-31 21:01:04.486233804 +0000
--- src/version.c       2023-01-31 21:07:01.662174217 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1270,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
81. At social functions you introduce your husband as "my domain server."

 /// 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/20230131211411.34B521C0903%40moolenaar.net.

Raspunde prin e-mail lui