From 6310774e98a51a4a2ec550e39ba3e1a58f2d0caa Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 25 Feb 2011 17:08:59 +0000 Subject: [PATCH] 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 --- dbus/dbus-connection.c | 2 ++ dbus/dbus-pending-call.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index fad69c7..a917f9a 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 cfb2baf..f961319 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; } -- 2.7.4