0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

patch 9.0.1609: crash when an object indirectly references itself

Problem:    Crash when an object indirectly references itself.
Solution:   Avoid clearing an object while it is already being cleared.
            (closes #12494)
This commit is contained in:
Bram Moolenaar
2023-06-05 16:53:25 +01:00
parent 5c606846b9
commit f7ca56f719
3 changed files with 41 additions and 3 deletions

View File

@@ -925,6 +925,33 @@ func Test_class_garbagecollect()
echo Point.pl Point.pd
END
call v9.CheckScriptSuccess(lines)
let lines =<< trim END
vim9script
interface View
endinterface
class Widget
this.view: View
endclass
class MyView implements View
this.widget: Widget
def new()
# this will result in a circular reference to this object
this.widget = Widget.new(this)
enddef
endclass
var view = MyView.new()
# overwrite "view", will be garbage-collected next
view = MyView.new()
test_garbagecollect_now()
END
call v9.CheckScriptSuccess(lines)
endfunc
def Test_class_function()