mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3083: crash when passing null string to charclass()
Problem: Crash when passing null string to charclass(). Solution: Bail out when string pointer is NULL. (Christian Brabandt, closes #8498, closes #8260)
This commit is contained in:
committed by
Bram Moolenaar
parent
b836f631db
commit
72463f883c
@@ -5587,7 +5587,8 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED)
|
|||||||
void
|
void
|
||||||
f_charclass(typval_T *argvars, typval_T *rettv UNUSED)
|
f_charclass(typval_T *argvars, typval_T *rettv UNUSED)
|
||||||
{
|
{
|
||||||
if (check_for_string_arg(argvars, 0) == FAIL)
|
if (check_for_string_arg(argvars, 0) == FAIL
|
||||||
|
|| argvars[0].vval.v_string == NULL)
|
||||||
return;
|
return;
|
||||||
rettv->vval.v_number = mb_get_class(argvars[0].vval.v_string);
|
rettv->vval.v_number = mb_get_class(argvars[0].vval.v_string);
|
||||||
}
|
}
|
||||||
|
@@ -2169,6 +2169,8 @@ func Test_charclass()
|
|||||||
call assert_equal(1, charclass('.'))
|
call assert_equal(1, charclass('.'))
|
||||||
call assert_equal(2, charclass('x'))
|
call assert_equal(2, charclass('x'))
|
||||||
call assert_equal(3, charclass("\u203c"))
|
call assert_equal(3, charclass("\u203c"))
|
||||||
|
" this used to crash vim
|
||||||
|
call assert_equal(0, "xxx"[-1]->charclass())
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_eventhandler()
|
func Test_eventhandler()
|
||||||
|
@@ -755,6 +755,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 */
|
||||||
|
/**/
|
||||||
|
3083,
|
||||||
/**/
|
/**/
|
||||||
3082,
|
3082,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user