wplua: ref closure before invalidating it

invalidation may destroy the closure and this will trigger
_wplua_closure_finalize(), which will remove the closure from the
array while the original code is also trying to do the same

if we destroy the closure after it has been removed from the
array, _wplua_closure_finalize() will not remove anything and
will continue happily
This commit is contained in:
George Kiagiadakis 2021-05-22 10:48:36 +03:00
parent ac23e60267
commit 4e3ca5dc15

View file

@ -33,8 +33,10 @@ _wplua_closure_store_finalize (WpLuaClosureStore * self)
{
for (guint i = self->closures->len; i > 0; i--) {
GClosure *c = g_ptr_array_index (self->closures, i-1);
g_closure_ref (c);
g_closure_invalidate (c);
g_ptr_array_remove_index_fast (self->closures, i-1);
g_closure_unref (c);
}
g_ptr_array_unref (self->closures);
}