From 4b49f312a05214d5d1974f7ac2702ffb407fc558 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Apr 2023 13:17:32 +0800 Subject: vim-patch:8.2.0633: crash when using null partial in filter() Problem: Crash when using null partial in filter(). Solution: Fix crash. Add more tests. (Yegappan Lakshmanan, closes vim/vim#5976) https://github.com/vim/vim/commit/9d8d0b5c644ea53364d04403740b3f23e57c1497 Co-authored-by: Bram Moolenaar --- src/nvim/eval.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 6a8b24ceed..46cd837a73 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -789,6 +789,9 @@ int eval_expr_typval(const typval_T *expr, typval_T *argv, int argc, typval_T *r } } else if (expr->v_type == VAR_PARTIAL) { partial_T *const partial = expr->vval.v_partial; + if (partial == NULL) { + return FAIL; + } const char *const s = partial_name(partial); if (s == NULL || *s == NUL) { return FAIL; @@ -8640,8 +8643,9 @@ int typval_compare(typval_T *typ1, typval_T *typ2, exprtype_T type, bool ic) } if ((typ1->v_type == VAR_PARTIAL && typ1->vval.v_partial == NULL) || (typ2->v_type == VAR_PARTIAL && typ2->vval.v_partial == NULL)) { - // when a partial is NULL assume not equal - n1 = false; + // When both partials are NULL, then they are equal. + // Otherwise they are not equal. + n1 = (typ1->vval.v_partial == typ2->vval.v_partial); } else if (type_is) { if (typ1->v_type == VAR_FUNC && typ2->v_type == VAR_FUNC) { // strings are considered the same if their value is -- cgit