summaryrefslogtreecommitdiff
path: root/cups
diff options
context:
space:
mode:
authorSyam Sidhardhan <s.syam@samsung.com>2011-12-06 20:29:16 +0530
committerJohan Hedberg <johan.hedberg@intel.com>2011-12-08 12:44:28 +0200
commitc2ab28e6616477d48b2cf693bc01fa1cb940fd2a (patch)
treeee3abb444ba238f0543ce24b81b66ae8eb3d4343 /cups
parent440d8578a7668ffaacc84f1db30a8b28e8bf01ca (diff)
downloadbluez-c2ab28e6616477d48b2cf693bc01fa1cb940fd2a.tar.gz
cups: Fix D-Bus reply memory leaks
Diffstat (limited to 'cups')
-rw-r--r--cups/main.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/cups/main.c b/cups/main.c
index 7f3f4b0aa..a884c6e7b 100644
--- a/cups/main.c
+++ b/cups/main.c
@@ -348,10 +348,15 @@ static void remote_device_found(const char *adapter, const char *bdaddr,
dbus_message_unref(message);
+ if (!adapter_reply)
+ return;
+
if (dbus_message_get_args(adapter_reply, NULL,
DBUS_TYPE_OBJECT_PATH, &adapter,
- DBUS_TYPE_INVALID) == FALSE)
+ DBUS_TYPE_INVALID) == FALSE) {
+ dbus_message_unref(adapter_reply);
return;
+ }
}
message = dbus_message_new_method_call("org.bluez", adapter,
@@ -386,12 +391,16 @@ static void remote_device_found(const char *adapter, const char *bdaddr,
if (dbus_message_get_args(reply, NULL,
DBUS_TYPE_OBJECT_PATH, &object_path,
- DBUS_TYPE_INVALID) == FALSE)
+ DBUS_TYPE_INVALID) == FALSE) {
+ dbus_message_unref(reply);
return;
+ }
id = device_get_ieee1284_id(adapter, object_path);
add_device_to_list(name, bdaddr, id);
g_free(id);
+
+ dbus_message_unref(reply);
}
static void discovery_completed(void)
@@ -642,10 +651,15 @@ static gboolean print_ieee1284(const char *bdaddr)
dbus_message_unref(message);
+ if (!adapter_reply)
+ return FALSE;
+
if (dbus_message_get_args(adapter_reply, NULL,
DBUS_TYPE_OBJECT_PATH, &adapter,
- DBUS_TYPE_INVALID) == FALSE)
+ DBUS_TYPE_INVALID) == FALSE) {
+ dbus_message_unref(adapter_reply);
return FALSE;
+ }
message = dbus_message_new_method_call("org.bluez", adapter,
"org.bluez.Adapter",
@@ -680,15 +694,21 @@ static gboolean print_ieee1284(const char *bdaddr)
if (dbus_message_get_args(reply, NULL,
DBUS_TYPE_OBJECT_PATH, &object_path,
- DBUS_TYPE_INVALID) == FALSE)
+ DBUS_TYPE_INVALID) == FALSE) {
+ dbus_message_unref(reply);
return FALSE;
+ }
id = device_get_ieee1284_id(adapter, object_path);
- if (id == NULL)
+ if (id == NULL) {
+ dbus_message_unref(reply);
return FALSE;
+ }
printf("%s", id);
g_free(id);
+ dbus_message_unref(reply);
+
return TRUE;
}