aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-15 13:17:32 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-15 13:31:10 +0800
commit4b49f312a05214d5d1974f7ac2702ffb407fc558 (patch)
treef4f7515c461d2d599e60b043995843fa54062f3e /src/nvim/eval.c
parent3d80392cab8ba41757769e18ffde9e8258365472 (diff)
downloadrneovim-4b49f312a05214d5d1974f7ac2702ffb407fc558.tar.gz
rneovim-4b49f312a05214d5d1974f7ac2702ffb407fc558.tar.bz2
rneovim-4b49f312a05214d5d1974f7ac2702ffb407fc558.zip
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 <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c8
1 files changed, 6 insertions, 2 deletions
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