]> granicus.if.org Git - vim/commitdiff
patch 8.2.4436: crash with weird 'vartabstop' value v8.2.4436
authorBram Moolenaar <Bram@vim.org>
Mon, 21 Feb 2022 19:36:12 +0000 (19:36 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 21 Feb 2022 19:36:12 +0000 (19:36 +0000)
Problem:    Crash with weird 'vartabstop' value.
Solution:   Check for running into the end of the line.

src/indent.c
src/testdir/test_vartabs.vim
src/version.c

index 95fc74ee46ab63bb74e4fe3aa81521817d94bf70..95bda20725edcea109317c6ec090d041313529c0 100644 (file)
@@ -1338,6 +1338,8 @@ change_indent(
                new_cursor_col += (*mb_ptr2len)(ptr + new_cursor_col);
            else
                ++new_cursor_col;
+           if (ptr[new_cursor_col] == NUL)
+               break;
            vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol);
        }
        vcol = last_vcol;
index 156233dca70d890c3e433c514f834e412eaaaa4d..d21acfe3a76c5075ad0478bf8a396fe6834f1514 100644 (file)
@@ -442,4 +442,16 @@ func Test_shiftwidth_vartabstop()
   setlocal shiftwidth& vartabstop& tabstop&
 endfunc
 
+func Test_vartabstop_latin1()
+  let save_encoding = &encoding
+  new
+  set encoding=iso8859
+  silent norm :se \ 1\e
+  set vartabstop=400
+  norm i00     \ 4
+  bwipe!
+  let &encoding = save_encoding
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index 9e21411946d10ec1c533c347b3894eaed0bd07b3..6eae5e66fdf6e556fb8d7e4de41811b904067250 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4436,
 /**/
     4435,
 /**/