diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-09-04 07:51:01 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-09-04 07:51:01 +0200 |
commit | e651e110c17656a263dd017b14c85b332163a58d (patch) | |
tree | 5aed78b4cba519728d28960297d9390944e02d1c /src/eval.c | |
parent | 233f956bd43279db1fb4d017acb4e56a1504addf (diff) |
patch 9.0.1862: Vim9 Garbage Collection issuesv9.0.1862
Problem: Vim9 Garbage Collection issues
Solution: Class members are garbage collected early leading to
use-after-free problems. Handle the garbage
collection of classes properly.
closes: #13019
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c index ad02c2c965..4143dd2ac6 100644 --- a/src/eval.c +++ b/src/eval.c @@ -5305,6 +5305,8 @@ garbage_collect(int testing) abort = abort || set_ref_in_popups(copyID); #endif + abort = abort || set_ref_in_classes(copyID); + if (!abort) { /* @@ -5353,6 +5355,9 @@ free_unref_items(int copyID) // Go through the list of objects and free items without this copyID. did_free |= object_free_nonref(copyID); + // Go through the list of classes and free items without this copyID. + did_free |= class_free_nonref(copyID); + #ifdef FEAT_JOB_CHANNEL // Go through the list of jobs and free items without the copyID. This // must happen before doing channels, because jobs refer to channels, but @@ -5707,7 +5712,7 @@ set_ref_in_item_channel( * Mark the class "cl" with "copyID". * Also see set_ref_in_item(). */ - static int + int set_ref_in_item_class( class_T *cl, int copyID, @@ -5716,8 +5721,7 @@ set_ref_in_item_class( { int abort = FALSE; - if (cl == NULL || cl->class_copyID == copyID - || (cl->class_flags & CLASS_INTERFACE) != 0) + if (cl == NULL || cl->class_copyID == copyID) return FALSE; cl->class_copyID = copyID; |