]> granicus.if.org Git - vim/commitdiff
patch 8.2.4440: crash with specific regexp pattern and string v8.2.4440
authorBram Moolenaar <Bram@vim.org>
Tue, 22 Feb 2022 13:37:31 +0000 (13:37 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 22 Feb 2022 13:37:31 +0000 (13:37 +0000)
Problem:    Crash with specific regexp pattern and string.
Solution:   Stop at the start of the string.

src/regexp_bt.c
src/testdir/test_regexp_utf8.vim
src/version.c

index 5f5e58f834fcd23dee43cbe92b18b0761cf6264b..4082f59d35cc31dd9968152af42c05a933ee999e 100644 (file)
@@ -4615,6 +4615,11 @@ regmatch(
                            if (rex.input == rex.line)
                            {
                                // backup to last char of previous line
+                               if (rex.lnum == 0)
+                               {
+                                   status = RA_NOMATCH;
+                                   break;
+                               }
                                --rex.lnum;
                                rex.line = reg_getline(rex.lnum);
                                // Just in case regrepeat() didn't count
index 674eee571d36b17309e866bc3164f358cafdf763..9f5b28816029df2429fe24cd848c5841cb5f867d 100644 (file)
@@ -508,7 +508,6 @@ endfunc
 " Check that [[:upper:]] matches for automatic engine
 func Test_match_char_class_upper()
   new
-  let _engine=&regexpengine
 
   " Test 1: [[:upper:]]\{2,\}
   set regexpengine=0
@@ -549,7 +548,7 @@ func Test_match_char_class_upper()
   call assert_equal(4, searchcount().total, 'TEST 3 lower')
 
   " clean up
-  let &regexpengine=_engine
+  set regexpengine=0
   bwipe!
 endfunc
 
@@ -561,4 +560,13 @@ func Test_match_invalid_byte()
   call delete('Xinvalid')
 endfunc
 
+func Test_match_too_complicated()
+  set regexpengine=1
+  exe "vsplit \xeb\xdb\x99"
+  silent! buf \&\zs*\zs*0
+  bwipe!
+  set regexpengine=0
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index 23f45b5c17c0708a56e3f168febb492fed82f954..809b03f3e51837355243c60831994c82196137c9 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4440,
 /**/
     4439,
 /**/