]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0515: Vim9: segfault in object_equal() v9.1.0515
authorErnie Rael <errael@raelity.com>
Sun, 23 Jun 2024 07:54:45 +0000 (09:54 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 23 Jun 2024 07:54:45 +0000 (09:54 +0200)
Problem:  Vim9: segfault in object_equal()
Solution: test for object pointer being NULL, before dereferencing them
          (Ernie Rael)

closes: #15085

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

index c363cf0a9a9041f3dcc22a72dfea08933f74dec7..a043f8c6999409d35eb3966d82253d3693e6224f 100644 (file)
@@ -10502,6 +10502,20 @@ def Test_Object_Compare_With_Recursive_Class_Ref()
     assert_equal(true, result)
   END
   v9.CheckScriptSuccess(lines)
+
+  lines =<< trim END
+    vim9script
+
+    class C
+        public var nest: C
+    endclass
+    var o1 = C.new()
+    var o2 = C.new(C.new())
+
+    var result = o1 == o2
+    assert_equal(false, result)
+  END
+  v9.CheckScriptSuccess(lines)
 enddef
 
 " Test for using a compound operator from a lambda function in an object method
index 391ac7365e2f888e6d94defdc9912d57ef0f6049..357f9c1e39752252f77c647dc975c45b910ad209 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    515,
 /**/
     514,
 /**/
index 4d0b4e8dd6c0740f5b494deb42f92203a93f6077..5d68459de851e63ceae254d15f74d44666b9a72b 100644 (file)
@@ -3855,6 +3855,8 @@ object_equal(
 
     if (o1 == o2)
        return TRUE;
+    if (o1 == NULL || o2 == NULL)
+       return FALSE;
 
     cl1 = o1->obj_class;
     cl2 = o2->obj_class;