From: Simon McVittie Date: Fri, 25 Feb 2011 17:08:59 +0000 (+0000) Subject: Comment some places where it's OK to unref a message despite holding locks X-Git-Tag: dbus-1.5.6~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6310774e98a51a4a2ec550e39ba3e1a58f2d0caa;p=thirdparty%2Fdbus.git Comment some places where it's OK to unref a message despite holding locks In general, dbus_message_unref should be avoided while holding locks, because it can invoke arbitrary user callbacks (via attached data, or via DBusCounter). Reviewed-by: Colin Walters Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34393 --- diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index fad69c73c..a917f9a91 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -4701,6 +4701,8 @@ dbus_connection_dispatch (DBusConnection *connection) if (preallocated == NULL) { + /* It's OK that this is finalized, because it hasn't been seen by + * anything that could attach user callbacks */ dbus_message_unref (reply); result = DBUS_HANDLER_RESULT_NEED_MEMORY; _dbus_verbose ("no memory for error send in dispatch\n"); diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c index cfb2bafe2..f9613195a 100644 --- a/dbus/dbus-pending-call.c +++ b/dbus/dbus-pending-call.c @@ -353,6 +353,8 @@ _dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending, reply_link = _dbus_list_alloc_link (reply); if (reply_link == NULL) { + /* it's OK to unref this, nothing that could have attached a callback + * has ever seen it */ dbus_message_unref (reply); return FALSE; }