diff options
author | Simo Sorce <idra@samba.org> | 2008-12-09 16:15:18 -0500 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2008-12-09 16:48:45 -0500 |
commit | dd42f1e418addaedbeeff9602520288edf3c7108 (patch) | |
tree | 2f176cc7ba2dc26e93fd844b9c0e40484a2ed0d8 | |
parent | 8f86577722f9e880c82e7a98fcb14ee06acb7170 (diff) | |
download | sssd-dd42f1e418addaedbeeff9602520288edf3c7108.tar.gz sssd-dd42f1e418addaedbeeff9602520288edf3c7108.tar.bz2 sssd-dd42f1e418addaedbeeff9602520288edf3c7108.zip |
Fix dbus related memory leaks
-rw-r--r-- | server/monitor.c | 18 | ||||
-rw-r--r-- | server/providers/data_provider.c | 20 | ||||
-rw-r--r-- | server/sbus/sssd_dbus_server.c | 6 |
3 files changed, 29 insertions, 15 deletions
diff --git a/server/monitor.c b/server/monitor.c index 0075aac7..38510f17 100644 --- a/server/monitor.c +++ b/server/monitor.c @@ -508,6 +508,7 @@ static int dbus_service_init(struct sbus_conn_ctx *conn_ctx, void *data) * We'll drop it using the default destructor. */ DEBUG(0, ("D-BUS send failed.\n")); + dbus_message_unref(msg); talloc_free(conn_ctx); return EIO; } @@ -545,7 +546,7 @@ static void identity_check(DBusPendingCall *pending, void *data) /* Destroy this connection */ sbus_disconnect(conn_ctx); - return; + goto done; } type = dbus_message_get_type(reply); @@ -558,7 +559,7 @@ static void identity_check(DBusPendingCall *pending, void *data) if (!ret) { DEBUG(1,("Failed, to parse message, killing connection\n")); sbus_disconnect(conn_ctx); - return; + goto done; } /* search this service in the list */ @@ -573,7 +574,7 @@ static void identity_check(DBusPendingCall *pending, void *data) if (!svc) { DEBUG(0,("Unable to find peer in list of services, killing connection!\n")); sbus_disconnect(conn_ctx); - return; + goto done; } /* transfer all from the fake service and get rid of it */ @@ -599,6 +600,10 @@ static void identity_check(DBusPendingCall *pending, void *data) sbus_disconnect(conn_ctx); return; } + +done: + dbus_pending_call_unref(pending); + dbus_message_unref(reply); } /* service_send_ping @@ -681,7 +686,7 @@ static void ping_check(DBusPendingCall *pending, void *data) /* Destroy this connection */ sbus_disconnect(conn_ctx); - return; + goto done; } type = dbus_message_get_type(reply); @@ -713,8 +718,11 @@ static void ping_check(DBusPendingCall *pending, void *data) * We'll destroy it now. */ sbus_disconnect(conn_ctx); - return; } + +done: + dbus_pending_call_unref(pending); + dbus_message_unref(reply); } /* service_check_alive diff --git a/server/providers/data_provider.c b/server/providers/data_provider.c index 181e865a..3bd0ef59 100644 --- a/server/providers/data_provider.c +++ b/server/providers/data_provider.c @@ -243,6 +243,7 @@ static int dbus_dp_init(struct sbus_conn_ctx *conn_ctx, void *data) */ DEBUG(0, ("D-BUS send failed.\n")); talloc_free(conn_ctx); + dbus_message_unref(msg); return EIO; } @@ -282,7 +283,7 @@ static void identity_check(DBusPendingCall *pending, void *data) /* Destroy this connection */ sbus_disconnect(dpcli->conn_ctx); - return; + goto done; } type = dbus_message_get_type(reply); @@ -297,7 +298,7 @@ static void identity_check(DBusPendingCall *pending, void *data) if (!ret) { DEBUG(1,("Failed, to parse message, killing connection\n")); sbus_disconnect(dpcli->conn_ctx); - return; + goto done; } switch (cli_type && DP_CLI_TYPE_MASK) { @@ -306,7 +307,7 @@ static void identity_check(DBusPendingCall *pending, void *data) if (!dpbe) { DEBUG(0, ("Out of memory!\n")); sbus_disconnect(dpcli->conn_ctx); - return; + goto done; } dpbe->name = talloc_strdup(dpbe, cli_name); @@ -314,7 +315,7 @@ static void identity_check(DBusPendingCall *pending, void *data) if (!dpbe->name || !dpbe->domain) { DEBUG(0, ("Out of memory!\n")); sbus_disconnect(dpcli->conn_ctx); - return; + goto done; } dpbe->dpcli = dpcli; @@ -329,14 +330,14 @@ static void identity_check(DBusPendingCall *pending, void *data) if (!dpfe) { DEBUG(0, ("Out of memory!\n")); sbus_disconnect(dpcli->conn_ctx); - return; + goto done; } dpfe->name = talloc_strdup(dpfe, cli_name); if (!dpfe->name) { DEBUG(0, ("Out of memory!\n")); sbus_disconnect(dpcli->conn_ctx); - return; + goto done; } dpfe->dpcli = dpcli; @@ -349,7 +350,7 @@ static void identity_check(DBusPendingCall *pending, void *data) default: DEBUG(1, ("Unknown client type, killing connection\n")); sbus_disconnect(dpcli->conn_ctx); - return; + goto done; } /* Set up the destructor for this service */ @@ -368,8 +369,11 @@ static void identity_check(DBusPendingCall *pending, void *data) * We'll destroy it now. */ sbus_disconnect(dpcli->conn_ctx); - return; } + +done: + dbus_pending_call_unref(pending); + dbus_message_unref(reply); } static void online_check(DBusPendingCall *pending, void *data) diff --git a/server/sbus/sssd_dbus_server.c b/server/sbus/sssd_dbus_server.c index abc9c863..182e3101 100644 --- a/server/sbus/sssd_dbus_server.c +++ b/server/sbus/sssd_dbus_server.c @@ -261,6 +261,7 @@ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, DBusServer *dbus_server; DBusError dbus_error; dbus_bool_t dbret; + char *tmp; /* Set up D-BUS server */ dbus_error_init(&dbus_error); @@ -271,8 +272,9 @@ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, return EIO; } - DEBUG(3, ("D-BUS Server listening on %s\n", - dbus_server_get_address(dbus_server))); + tmp = dbus_server_get_address(dbus_server); + DEBUG(3, ("D-BUS Server listening on %s\n", tmp)); + free(tmp); srv_ctx = talloc_zero(ev, struct sbus_srv_ctx); if (!srv_ctx) { |