mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Problem: Crash when using submatch(0, 1) in substitute(). Solution: Increment reference count. (closes #6887)
This commit is contained in:
@@ -2543,6 +2543,7 @@ reg_submatch_list(int no)
|
|||||||
list_free(list);
|
list_free(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
++list->lv_refcount;
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -881,6 +881,12 @@ func Test_invalid_submatch()
|
|||||||
call assert_equal([], submatch(1, 1))
|
call assert_equal([], submatch(1, 1))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_submatch_list_concatenate()
|
||||||
|
let pat = 'A\(.\)'
|
||||||
|
let Rep = {-> string([submatch(0, 1)] + [[submatch(1)]])}
|
||||||
|
call substitute('A1', pat, Rep, '')->assert_equal("[['A1'], ['1']]")
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_substitute_expr_arg()
|
func Test_substitute_expr_arg()
|
||||||
call assert_equal('123456789-123456789=', substitute('123456789',
|
call assert_equal('123456789-123456789=', substitute('123456789',
|
||||||
\ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
|
\ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1621,
|
||||||
/**/
|
/**/
|
||||||
1620,
|
1620,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user