]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1942: Vim9: execution stack invalidated with null object v9.0.1942
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 25 Sep 2023 19:00:46 +0000 (21:00 +0200)
committerChristian Brabandt <cb@256bit.org>
Mon, 25 Sep 2023 19:00:46 +0000 (21:00 +0200)
Problem:  Vim9: execution stack invalidated with null object
Solution: Check for a null object before adjusting the execution stack

closes: #13186

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
src/version.c
src/vim9execute.c

index 168c10cacb94255a843ad260bcf66b88f2cb50aa..e48c564e81feeddce9c2a7838994d5409740e174 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1942,
 /**/
     1941,
 /**/
index 02a37e8bfbb77254cf1d872a4f9268a8294a7cc5..0700eb78094b301ce0b9e828ffeea25ecc0392e0 100644 (file)
@@ -535,6 +535,15 @@ call_dfunc(
     // If this is an object method, the object is just before the arguments.
     typval_T   *obj = STACK_TV_BOT(0) - argcount - vararg_count - 1;
 
+    if (IS_OBJECT_METHOD(ufunc) && !IS_CONSTRUCTOR_METHOD(ufunc)
+           && obj->v_type == VAR_OBJECT && obj->vval.v_object == NULL)
+    {
+       // If this is not a constructor method, then a valid object is
+       // needed.
+       emsg(_(e_using_null_object));
+       return FAIL;
+    }
+
     // Check the argument types.
     if (check_ufunc_arg_types(ufunc, argcount, vararg_count, ectx) == FAIL)
        return FAIL;
@@ -601,15 +610,6 @@ call_dfunc(
     // the first local variable.
     if (IS_OBJECT_METHOD(ufunc))
     {
-       if (obj->v_type == VAR_OBJECT && obj->vval.v_object == NULL
-                                           && !IS_CONSTRUCTOR_METHOD(ufunc))
-       {
-           // If this is not a constructor method, then a valid object is
-           // needed.
-           emsg(_(e_using_null_object));
-           return FAIL;
-       }
-
        *STACK_TV_VAR(0) = *obj;
        obj->v_type = VAR_UNKNOWN;
     }