]> granicus.if.org Git - vim/commitdiff
patch 8.2.4418: crash when using special multi-byte character v8.2.4418
authorBram Moolenaar <Bram@vim.org>
Sat, 19 Feb 2022 11:20:12 +0000 (11:20 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 19 Feb 2022 11:20:12 +0000 (11:20 +0000)
Problem:    Crash when using special multi-byte character.
Solution:   Don't use isalpha() for an arbitrary character.

src/charset.c
src/filepath.c
src/proto/charset.pro
src/testdir/test_autochdir.vim
src/version.c

index 2ecb96c894ad81ff19e09b11809d9f93f7dd41e5..ed09bd23f4410943581245f2254f72cb29ab8df1 100644 (file)
@@ -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)
 {
index 929fa56a4d05df8e39332e4610d06110f0bf5f43..7a5dae441fd55e55893f97a6c0a1c576cc50c4be 100644 (file)
@@ -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)
        {
index ee5370bccdb6b841eb01917586811602bfc6c6f4..df097109c12ecf19d7c6ffec9cbfff8df9f235a7 100644 (file)
@@ -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);
@@ -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 : */
index 5d367757fcc4d7d738fb501561f526b231ba3af5..95004d278a85c68fc73b04d996f04dc2c8f1cfb5 100644 (file)
@@ -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
index f95b395b7a2eabe0cef0c71f65a367b01e28ac97..5cb7218706ce4aa4d68ac2a1e762b24449400316 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4418,
 /**/
     4417,
 /**/