From 62c2a02cb6228bb42f5756232e83b70ff1d02da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 21 Jan 2012 20:10:45 +0000 Subject: [PATCH] [GB.DBUS] * BUG: Fix memory leaks in DBus error management. git-svn-id: svn://localhost/gambas/trunk@4414 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.dbus/src/c_dbusconnection.c | 4 +--- gb.dbus/src/c_dbusobserver.c | 8 ++++++-- gb.dbus/src/helper.c | 4 ++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gb.dbus/src/c_dbusconnection.c b/gb.dbus/src/c_dbusconnection.c index 65e59464e..7be79f03c 100644 --- a/gb.dbus/src/c_dbusconnection.c +++ b/gb.dbus/src/c_dbusconnection.c @@ -32,10 +32,8 @@ static CDBUSCONNECTION *_session = NULL; static DBusConnection *get_bus(DBusBusType type) { DBusConnection *conn; - DBusError error; - dbus_error_init (&error); - conn = dbus_bus_get(type, &error); + conn = dbus_bus_get(type, NULL); if (!conn) GB.Error("Cannot connect to the &1 bus", type == DBUS_BUS_SYSTEM ? "system" : "session"); else diff --git a/gb.dbus/src/c_dbusobserver.c b/gb.dbus/src/c_dbusobserver.c index 49bca5b8a..d9ba7af18 100644 --- a/gb.dbus/src/c_dbusobserver.c +++ b/gb.dbus/src/c_dbusobserver.c @@ -112,7 +112,9 @@ static void update_match(CDBUSOBSERVER *_object, bool noerr) dbus_bus_add_match(THIS->connection, match, &error); if (dbus_error_is_set(&error)) { - if (!noerr) GB.Error("Cannot enable observer"); + if (!noerr) + GB.Error("Cannot enable observer"); + dbus_error_free(&error); THIS->enabled = FALSE; DBUS_watch(THIS->connection, FALSE); } @@ -124,7 +126,9 @@ static void update_match(CDBUSOBSERVER *_object, bool noerr) dbus_bus_remove_match(THIS->connection, match, &error); if (dbus_error_is_set(&error)) { - if (!noerr) GB.Error("Cannot disable observer"); + if (!noerr) + GB.Error("Cannot disable observer"); + dbus_error_free(&error); THIS->enabled = TRUE; DBUS_watch(THIS->connection, TRUE); } diff --git a/gb.dbus/src/helper.c b/gb.dbus/src/helper.c index c0581c50c..4fe42de1b 100644 --- a/gb.dbus/src/helper.c +++ b/gb.dbus/src/helper.c @@ -754,6 +754,7 @@ bool DBUS_call_method(DBusConnection *connection, const char *application, const GB.Error("&1: &2", error.name, error.message); if (reply) dbus_message_unref(reply); + dbus_error_free(&error); goto __RETURN; } @@ -939,6 +940,7 @@ char *DBUS_introspect(DBusConnection *connection, const char *application, const if (dbus_error_is_set(&error)) { GB.Error("&1: &2", error.name, error.message); + dbus_error_free(&error); goto __RETURN; } @@ -1068,6 +1070,7 @@ bool DBUS_register(DBusConnection *connection, const char *name, bool unique) if (dbus_error_is_set(&error)) { GB.Error("Unable to register application name"); + dbus_error_free(&error); return TRUE; } @@ -1089,6 +1092,7 @@ bool DBUS_unregister(DBusConnection *connection, const char *name) if (dbus_error_is_set(&error)) { GB.Error("Unable to unregister application name"); + dbus_error_free(&error); return TRUE; }