changeset 27410:5d6774c0df4f v8.2.4233

patch 8.2.4233: crash when recording and using Select mode Commit: https://github.com/vim/vim/commit/a4bc2dd7cccf5a4a9f78b58b6f35a45d17164323 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 27 19:27:16 2022 +0000 patch 8.2.4233: crash when recording and using Select mode Problem: Crash when recording and using Select mode. Solution: When deleting the last recorded character check there is something to delete.
author Bram Moolenaar <Bram@vim.org>
date Thu, 27 Jan 2022 20:30:07 +0100
parents 00712672b53f
children 2689052e59cd
files src/getchar.c src/testdir/test_registers.vim src/version.c
diffstat 3 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -252,8 +252,11 @@ add_buff(
     static void
 delete_buff_tail(buffheader_T *buf, int slen)
 {
-    int len = (int)STRLEN(buf->bh_curr->b_str);
-
+    int len;
+
+    if (buf->bh_curr == NULL || buf->bh_curr->b_str == NULL)
+	return;  // nothing to delete
+    len = (int)STRLEN(buf->bh_curr->b_str);
     if (len >= slen)
     {
 	buf->bh_curr->b_str[len - slen] = NUL;
--- a/src/testdir/test_registers.vim
+++ b/src/testdir/test_registers.vim
@@ -739,6 +739,15 @@ func Test_record_in_insert_mode()
   bwipe!
 endfunc
 
+func Test_record_in_select_mode()
+  new
+  call setline(1, 'text')
+  sil norm q00
+  sil norm q
+  call assert_equal('0ext', getline(1))
+  bwipe!
+endfunc
+
 " Make sure that y_append is correctly reset
 " and the previous register is working as expected
 func Test_register_y_append_reset()
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4233,
+/**/
     4232,
 /**/
     4231,