]> granicus.if.org Git - vim/commitdiff
patch 8.2.4233: crash when recording and using Select mode v8.2.4233
authorBram Moolenaar <Bram@vim.org>
Thu, 27 Jan 2022 19:27:16 +0000 (19:27 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 27 Jan 2022 19:27:16 +0000 (19:27 +0000)
Problem:    Crash when recording and using Select mode.
Solution:   When deleting the last recorded character check there is something
            to delete.

src/getchar.c
src/testdir/test_registers.vim
src/version.c

index c0dfc2b0b89979d0d413aec9d40de8453a03d79a..49eb3d7df9e866bce753d68a75bd792aaa89d14e 100644 (file)
@@ -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;
index bbc7c1911d2bdb5fde30f6d08e3bc75b9830ead7..89d9d7cad7c46fae95d2c7f2f4e50c50f5cb9c2b 100644 (file)
@@ -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 \16q0\a0
+  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()
index 2f872e98110e4d560d35652f6e4d5520ed25fd2a..bc956cee0a66acedcf911785ec5dd05c8c7e2120 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4233,
 /**/
     4232,
 /**/