]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1592: Vim9: crash with classes and garbage collection v9.1.1592
authorYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 5 Aug 2025 17:17:51 +0000 (19:17 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 5 Aug 2025 17:17:51 +0000 (19:17 +0200)
Problem:  Vim9: crash with classes and garbage collection
          (Christian J. Robinson, after v9.1.1566)
Solution: When getting the references to an object, make sure the object
          is valid (Yegappan Lakshmanan)

closes: #17860

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

index cb645463919310c9e7f4b4c7f0a5160ba8c293d9..fecf9219f08b69bb03e6a5ed6be03638f3913fe7 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1592,
 /**/
     1591,
 /**/
index aa68a6dc8aeeaae583ede243ae624ccf8953968d..40b594af79f86306d9e49e55354cc20b312c327f 100644 (file)
@@ -3714,7 +3714,8 @@ class_get_selfrefs(class_T *cl)
     for (int i = 0; i < cl->class_class_member_count; ++i)
     {
        tv = &cl->class_members_tv[i];
-       if (tv->v_type == VAR_OBJECT && tv->vval.v_object->obj_class == cl
+       if (tv->v_type == VAR_OBJECT && tv->vval.v_object != NULL
+               && tv->vval.v_object->obj_class == cl
                && (tv->vval.v_object->obj_refcount == 1
                    || (IS_ENUM(cl) && tv->vval.v_object->obj_refcount == 2)))
            self_refs++;