]> granicus.if.org Git - vim/commitdiff
patch 8.2.3625: illegal memory access when C-indenting v8.2.3625
authorBram Moolenaar <Bram@vim.org>
Fri, 19 Nov 2021 19:41:13 +0000 (19:41 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 19 Nov 2021 19:41:13 +0000 (19:41 +0000)
Problem:    Illegal memory access when C-indenting.
Solution:   Also set the cursor column.

src/cindent.c
src/testdir/test_cindent.vim
src/version.c

index 850a36994732cb52347a657ba57ab42b92a07f51..ad3052249dc8fdee4440299fda58656351ce9cae 100644 (file)
@@ -1637,10 +1637,10 @@ get_baseclass_amount(int col)
     static pos_T *
 find_start_brace(void)     // XXX
 {
-    pos_T      cursor_save;
-    pos_T      *trypos;
-    pos_T      *pos;
-    static pos_T       pos_copy;
+    pos_T          cursor_save;
+    pos_T          *trypos;
+    pos_T          *pos;
+    static pos_T    pos_copy;
 
     cursor_save = curwin->w_cursor;
     while ((trypos = findmatchlimit(NULL, '{', FM_BLOCKSTOP, 0)) != NULL)
@@ -1654,7 +1654,7 @@ find_start_brace(void)        // XXX
                       && (pos = ind_find_start_CORS(NULL)) == NULL) // XXX
            break;
        if (pos != NULL)
-           curwin->w_cursor.lnum = pos->lnum;
+           curwin->w_cursor = *pos;
     }
     curwin->w_cursor = cursor_save;
     return trypos;
index 3a536c4c89a54ea183aa6ff28219cca2c2ceba5c..c097ca766d463679b263387a217184f0af53baaf 100644 (file)
@@ -5314,4 +5314,16 @@ func Test_backslash_at_end_of_line()
   bwipe!
 endfunc
 
+func Test_find_brace_backwards()
+  " this was looking beyond the end of the line
+  new
+  norm R/*
+  norm o0{
+  norm o//
+  norm V{=
+  call assert_equal(['/*', '   0{', '//'], getline(1, 3))
+  bwipe!
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index 7cadcebf04d2ca10344ec5937a6179a40573bbf2..8e84cbb4569a42c6c23c4f2c51dfcbf642f36566 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3625,
 /**/
     3624,
 /**/