]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0513: Vim9: segfault with object comparison v9.1.0513
authorErnie Rael <errael@raelity.com>
Sat, 22 Jun 2024 09:12:00 +0000 (11:12 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 22 Jun 2024 09:12:00 +0000 (11:12 +0200)
Problem:  Vim9: segfault with object comparisons
Solution: increment recusive_cnt before calling typval_compare_object()
          (Ernie Rael)

closes: #15073

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_class.vim
src/typval.c
src/version.c

index e92fcc57366eb1956bbd37954490a0d945c24848..c363cf0a9a9041f3dcc22a72dfea08933f74dec7 100644 (file)
@@ -10486,6 +10486,24 @@ def Test_Ref_Class_Within_Same_Class()
   v9.CheckScriptFailure(lines, 'E1347: Not a valid interface: A', 3)
 enddef
 
+" Test for comparing a class referencing itself
+def Test_Object_Compare_With_Recursive_Class_Ref()
+  var lines =<< trim END
+    vim9script
+
+    class C
+    public var nest: C
+    endclass
+
+    var o1 = C.new()
+    o1.nest = o1
+
+    var result = o1 == o1
+    assert_equal(true, result)
+  END
+  v9.CheckScriptSuccess(lines)
+enddef
+
 " Test for using a compound operator from a lambda function in an object method
 def Test_compound_op_in_objmethod_lambda()
   # Test using the "+=" operator
index 6a73719b7136c8455decc2e98360cce92cc726c5..76ce405a70d44e2508ef1c844f05e50d4e02fb5b 100644 (file)
@@ -2114,7 +2114,9 @@ tv_equal(
            return tv1->vval.v_class == tv2->vval.v_class;
 
        case VAR_OBJECT:
+           ++recursive_cnt;
            (void)typval_compare_object(tv1, tv2, EXPR_EQUAL, ic, &r);
+           --recursive_cnt;
            return r;
 
        case VAR_PARTIAL:
index 41d9281a37b36632166abc9eafe033acf31f6bed..e8f6a2d0d194e5aa6463100dad55ee179873b016 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    513,
 /**/
     512,
 /**/