From 4e3ca5dc15961c436ff55f8e16922a5c3b0ff713 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Sat, 22 May 2021 10:48:36 +0300 Subject: [PATCH] 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 --- lib/wplua/closure.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/wplua/closure.c b/lib/wplua/closure.c index 269b2fa9..017ca749 100644 --- a/lib/wplua/closure.c +++ b/lib/wplua/closure.c @@ -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); }