vim-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 vim/vim#6887)
8a0dcf4330

N/A patches for version.c:

vim-patch:8.2.2674: Motif: cancelling the font dialog resets the font

Problem:    Motif: cancelling the font dialog resets the font.
Solution:   When no font is selected to not change the font. (closes vim/vim#7825,
            closes vim/vim#8035)  Fix compiler warnings.
9dbe701fe1
This commit is contained in:
Jan Edmund Lazo 2021-03-28 12:40:44 -04:00
parent 375f957af6
commit 4564f2c54f
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 10 additions and 0 deletions

View File

@ -7139,6 +7139,7 @@ list_T *reg_submatch_list(int no)
tv_list_append_string(list, s, (const char *)rsm.sm_match->endp[no] - s);
}
tv_list_ref(list);
return list;
}

View File

@ -746,3 +746,12 @@ func Test_sub_beyond_end()
call assert_equal('#', getline(1))
bwipe!
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']]")
call assert_equal(substitute('A1', pat, Rep, ''), "[['A1'], ['1']]")
endfunc
" vim: shiftwidth=2 sts=2 expandtab