Mercurial > vim
changeset 25092:cd5e8df05a64 v8.2.3083
patch 8.2.3083: crash when passing null string to charclass()
Commit: https://github.com/vim/vim/commit/72463f883cdfd08e29ab0018ef3889284848d5f1
Author: Christian Brabandt <cb@256bit.org>
Date: Fri Jul 2 20:19:31 2021 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 02 Jul 2021 20:30:05 +0200 |
parents | 143c87f12b9b |
children | 88cb0813ec24 |
files | src/mbyte.c src/testdir/test_functions.vim src/version.c |
diffstat | 3 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mbyte.c +++ b/src/mbyte.c @@ -5587,7 +5587,8 @@ f_setcellwidths(typval_T *argvars, typva void 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; rettv->vval.v_number = mb_get_class(argvars[0].vval.v_string); }
--- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -2169,6 +2169,8 @@ func Test_charclass() call assert_equal(1, charclass('.')) call assert_equal(2, charclass('x')) call assert_equal(3, charclass("\u203c")) + " this used to crash vim + call assert_equal(0, "xxx"[-1]->charclass()) endfunc func Test_eventhandler()