Skip to content

Commit

Permalink
patch 8.2.4436: crash with weird 'vartabstop' value
Browse files Browse the repository at this point in the history
Problem:    Crash with weird 'vartabstop' value.
Solution:   Check for running into the end of the line.
  • Loading branch information
brammool committed Feb 21, 2022
1 parent 7842761 commit 4e889f9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/indent.c
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions src/testdir/test_vartabs.vim
Expand Up @@ -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 
set vartabstop=400
norm i00 
bwipe!
let &encoding = save_encoding
endfunc


" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4436,
/**/
4435,
/**/
Expand Down

4 comments on commit 4e889f9

@k-takata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails on Windows: https://github.com/vim/vim/runs/5279219272?check_suite_focus=true#step:13:7478

Caught exception in Test_vartabstop_latin1(): Vim(set):E950: Cannot convert between cp1252 and iso-8859- @ command line..script D:/a/vim/vim/src/testdir/runtest.vim[456]..function RunTheTest[44]..Test_vartabstop_latin1, line 3

Maybe we should use set encoding=latin1 instead of set encoding=iso8859?

@k-takata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #9818, but it didn't work as expected...

@chrisbra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait a second, is iso8859 actually a valid encoding? Shouldn't it rather be iso8859-1 e.g. we are missing what kind of a iso-8859 encoding is used (latin1: -1, ... latin9: -15, etc)

@k-takata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that should be better.

Please sign in to comment.