Skip to content

Commit

Permalink
patch 8.2.4418: crash when using special multi-byte character
Browse files Browse the repository at this point in the history
Problem:    Crash when using special multi-byte character.
Solution:   Don't use isalpha() for an arbitrary character.
  • Loading branch information
brammool committed Feb 19, 2022
1 parent e89bfd2 commit 5921aeb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/charset.c
Expand Up @@ -1644,6 +1644,12 @@ vim_isupper(int c)
return isupper(c);
}

int
vim_isalpha(int c)
{
return vim_islower(c) || vim_isupper(c);
}

int
vim_toupper(int c)
{
Expand Down
2 changes: 1 addition & 1 deletion src/filepath.c
Expand Up @@ -3626,7 +3626,7 @@ unix_expandpath(
else if (path_end >= path + wildoff
&& (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL
|| (!p_fic && (flags & EW_ICASE)
&& isalpha(PTR2CHAR(path_end)))))
&& vim_isalpha(PTR2CHAR(path_end)))))
e = p;
if (has_mbyte)
{
Expand Down
2 changes: 1 addition & 1 deletion src/proto/charset.pro
Expand Up @@ -50,6 +50,7 @@ int vim_isxdigit(int c);
int vim_isbdigit(int c);
int vim_islower(int c);
int vim_isupper(int c);
int vim_isalpha(int c);
int vim_toupper(int c);
int vim_tolower(int c);
char_u *skiptowhite(char_u *p);
Expand All @@ -63,5 +64,4 @@ int hexhex2nr(char_u *p);
int rem_backslash(char_u *str);
void backslash_halve(char_u *p);
char_u *backslash_halve_save(char_u *p);
void ebcdic2ascii(char_u *buffer, int len);
/* vim: set ft=c : */
8 changes: 8 additions & 0 deletions src/testdir/test_autochdir.vim
Expand Up @@ -110,4 +110,12 @@ func Test_verbose_pwd()
call delete('Xautodir', 'rf')
endfunc

func Test_multibyte()
" using an invalid character should not cause a crash
set wic
call assert_fails('tc űŤŤŤ¦*', 'E344:')
set nowic
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 */
/**/
4418,
/**/
4417,
/**/
Expand Down

0 comments on commit 5921aeb

Please sign in to comment.