diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-06 15:14:45 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-06 15:14:45 +0200 |
commit | 8a0dcf43305586853f452a77fa295b0c8d54b463 (patch) | |
tree | ccf2c0ebb8744b84c55ca4c199f4d56708b6f7d6 | |
parent | 4140c4f3fff1a441f2837f2f911ab0f0368e412a (diff) | |
download | vim-git-8a0dcf43305586853f452a77fa295b0c8d54b463.tar.gz |
patch 8.2.1621: crash when using submatch(0, 1) in substitute()v8.2.1621
Problem: Crash when using submatch(0, 1) in substitute().
Solution: Increment reference count. (closes #6887)
-rw-r--r-- | src/regexp.c | 1 | ||||
-rw-r--r-- | src/testdir/test_substitute.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/regexp.c b/src/regexp.c index 229f6ef2b..375731c3c 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -2543,6 +2543,7 @@ reg_submatch_list(int no) list_free(list); return NULL; } + ++list->lv_refcount; return list; } #endif diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim index 61c9cb34e..a137aa527 100644 --- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -881,6 +881,12 @@ func Test_invalid_submatch() call assert_equal([], submatch(1, 1)) 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() call assert_equal('123456789-123456789=', substitute('123456789', \ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', diff --git a/src/version.c b/src/version.c index 36416ef17..cf7de76a6 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1621, +/**/ 1620, /**/ 1619, |