diff src/eval.c @ 20156:49694eceaa55 v8.2.0633

patch 8.2.0633: crash when using null partial in filter() Commit: https://github.com/vim/vim/commit/9d8d0b5c644ea53364d04403740b3f23e57c1497 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 24 22:47:31 2020 +0200 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 https://github.com/vim/vim/issues/5976)
author Bram Moolenaar <Bram@vim.org>
date Fri, 24 Apr 2020 23:00:04 +0200
parents fe8d0a4344df
children 94f05de75e9f
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -241,6 +241,9 @@ eval_expr_typval(typval_T *expr, typval_
     {
 	partial_T   *partial = expr->vval.v_partial;
 
+	if (partial == NULL)
+	    return FAIL;
+
 	if (partial->pt_func != NULL && partial->pt_func->uf_dfunc_idx >= 0)
 	{
 	    if (call_def_function(partial->pt_func, argc, argv, rettv) == FAIL)
@@ -6416,8 +6419,9 @@ typval_compare(
 					&& 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)