From 32b7f835d8fd7466c58ed84a20c46ba9c802e36b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Thu, 25 Jul 2024 11:55:53 +0200 Subject: [PATCH] Avoid potential crash on signal disconnection --- core/object/object.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/object/object.cpp b/core/object/object.cpp index ac23bf831fd..a2926a478d7 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -2097,7 +2097,11 @@ Object::~Object() { // Disconnect signals that connect to this object. while (connections.size()) { Connection c = connections.front()->get(); - bool disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true); + Object *obj = c.callable.get_object(); + bool disconnected = false; + if (likely(obj)) { + disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true); + } if (unlikely(!disconnected)) { // If the disconnect has failed, abandon the connection to avoid getting trapped in an infinite loop here. connections.pop_front();