summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/error.c20
-rw-r--r--hcid/dbus-error.c11
2 files changed, 27 insertions, 4 deletions
diff --git a/common/error.c b/common/error.c
index 51f4f4bc..096b8651 100644
--- a/common/error.c
+++ b/common/error.c
@@ -246,7 +246,11 @@ DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
if (!derr)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
- return dbus_connection_send_and_unref(conn, derr);
+ dbus_connection_send(conn, derr, NULL);
+
+ dbus_message_unref(derr);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
/**
@@ -256,6 +260,7 @@ DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
*/
DBusHandlerResult error_unknown_method(DBusConnection *conn, DBusMessage *msg)
{
+ DBusMessage *derr;
char error[128];
const char *signature = dbus_message_get_signature(msg);
const char *method = dbus_message_get_member(msg);
@@ -264,7 +269,14 @@ DBusHandlerResult error_unknown_method(DBusConnection *conn, DBusMessage *msg)
snprintf(error, 128, "Method \"%s\" with signature \"%s\" on interface \"%s\" doesn't exist",
method, signature, interface);
- return send_message_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".UnknownMethod",
- error));
+ derr = dbus_message_new_error(msg, ERROR_INTERFACE ".UnknownMethod",
+ error);
+ if (!derr)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ dbus_connection_send(conn, derr, NULL);
+
+ dbus_message_unref(derr);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
diff --git a/hcid/dbus-error.c b/hcid/dbus-error.c
index 98e06e9a..c1d1506a 100644
--- a/hcid/dbus-error.c
+++ b/hcid/dbus-error.c
@@ -39,6 +39,17 @@
#include "dbus-error.h"
#include "error.h"
+static inline DBusHandlerResult send_message_and_unref(DBusConnection *conn,
+ DBusMessage *msg)
+{
+ if (msg) {
+ dbus_connection_send(conn, msg, NULL);
+ dbus_message_unref(msg);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
DBusHandlerResult error_rejected(DBusConnection *conn, DBusMessage *msg)
{
return send_message_and_unref(conn,