[gnome-bluetooth] Fix memory leaks when using dbus_g_method_get_sender()
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] Fix memory leaks when using dbus_g_method_get_sender()
- Date: Mon, 14 Dec 2009 12:01:17 +0000 (UTC)
commit 13f92d32f2f17d32de86d4b04184fe945ea35f8c
Author: Bastien Nocera <hadess hadess net>
Date: Mon Dec 14 11:58:54 2009 +0000
Fix memory leaks when using dbus_g_method_get_sender()
lib/bluetooth-agent.c | 64 ++++++++++++++++++++++++++++++++++++------------
lib/obex-agent.c | 32 ++++++++++++++++++------
2 files changed, 72 insertions(+), 24 deletions(-)
---
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index 00e8dcb..a08eb9c 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -80,14 +80,18 @@ static gboolean bluetooth_agent_request_pin_code(BluetoothAgent *agent,
const char *path, DBusGMethodInvocation *context)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
DBusGProxy *device;
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->pincode_func) {
if (priv->adapter != NULL)
@@ -110,14 +114,18 @@ static gboolean bluetooth_agent_request_passkey(BluetoothAgent *agent,
const char *path, DBusGMethodInvocation *context)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
DBusGProxy *device;
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->passkey_func) {
if (priv->adapter != NULL)
@@ -141,14 +149,18 @@ static gboolean bluetooth_agent_display_passkey(BluetoothAgent *agent,
DBusGMethodInvocation *context)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
DBusGProxy *device;
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->display_func) {
if (priv->adapter != NULL)
@@ -172,14 +184,18 @@ static gboolean bluetooth_agent_request_confirmation(BluetoothAgent *agent,
DBusGMethodInvocation *context)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
DBusGProxy *device;
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->confirm_func) {
if (priv->adapter != NULL)
@@ -203,14 +219,18 @@ static gboolean bluetooth_agent_authorize(BluetoothAgent *agent,
DBusGMethodInvocation *context)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
DBusGProxy *device;
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->authorize_func) {
if (priv->adapter != NULL)
@@ -233,12 +253,16 @@ static gboolean bluetooth_agent_confirm_mode(BluetoothAgent *agent,
const char *mode, DBusGMethodInvocation *context)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
dbus_g_method_return(context);
@@ -249,13 +273,17 @@ static gboolean bluetooth_agent_cancel(BluetoothAgent *agent,
DBusGMethodInvocation *context)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->cancel_func)
result = priv->cancel_func(context, priv->cancel_data);
@@ -267,12 +295,16 @@ static gboolean bluetooth_agent_release(BluetoothAgent *agent,
DBusGMethodInvocation *context)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
g_object_unref(agent);
diff --git a/lib/obex-agent.c b/lib/obex-agent.c
index 714dc6a..38b2fde 100644
--- a/lib/obex-agent.c
+++ b/lib/obex-agent.c
@@ -73,13 +73,17 @@ static gboolean obex_agent_request(ObexAgent *agent, const char *path,
DBusGMethodInvocation *context)
{
ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->request_func) {
DBusGProxy *proxy;
@@ -102,13 +106,17 @@ static gboolean obex_agent_progress(ObexAgent *agent, const char *path,
guint64 transferred, DBusGMethodInvocation *context)
{
ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->progress_func) {
DBusGProxy *proxy;
@@ -130,13 +138,17 @@ static gboolean obex_agent_complete(ObexAgent *agent, const char *path,
DBusGMethodInvocation *context)
{
ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->complete_func) {
DBusGProxy *proxy;
@@ -158,13 +170,17 @@ static gboolean obex_agent_release(ObexAgent *agent,
DBusGMethodInvocation *context)
{
ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
- const char *sender = dbus_g_method_get_sender(context);
+ char *sender = dbus_g_method_get_sender(context);
gboolean result = FALSE;
DBG("agent %p sender %s", agent, sender);
- if (g_str_equal(sender, priv->busname) == FALSE)
+ if (g_str_equal(sender, priv->busname) == FALSE) {
+ g_free (sender);
return FALSE;
+ }
+
+ g_free (sender);
if (priv->release_func)
result = priv->release_func(context, priv->release_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]