Skip to content

Commit 1c815b5

Browse files
committed
patch 9.1.0700: crash with 2byte encoding and glob2regpat()
Problem: possible crash with 2byte encoding and glob2regpat() Solution: Skip over character, if it is multi-byte character Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent f8702ae commit 1c815b5

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/fileio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5714,7 +5714,8 @@ file_pat_to_reg_pat(
57145714
)
57155715
*allow_dirs = TRUE;
57165716
reg_pat[i++] = '\\';
5717-
reg_pat[i++] = *p;
5717+
if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
5718+
reg_pat[i++] = *p++;
57185719
}
57195720
break;
57205721
#ifdef BACKSLASH_IN_FILENAME
200 Bytes
Binary file not shown.

src/testdir/test_crash.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ func Test_crash1_3()
222222
call term_sendkeys(buf, args)
223223
call TermWait(buf, 150)
224224

225+
let file = 'crash/heap_overflow_glob2regpat'
226+
let cmn_args = "%s -u NONE -i NONE -n -X -m -n -e -s -S %s -c ':qa!'"
227+
let args = printf(cmn_args, vim, file)
228+
call term_sendkeys(buf, args)
229+
call TermWait(buf, 50)
230+
225231

226232
" clean up
227233
exe buf .. "bw!"

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
700,
707709
/**/
708710
699,
709711
/**/

0 commit comments

Comments
 (0)