diff options
author | Cidorvan Leite <cidorvan.leite@openbossa.org> | 2008-04-11 21:53:32 +0000 |
---|---|---|
committer | Cidorvan Leite <cidorvan.leite@openbossa.org> | 2008-04-11 21:53:32 +0000 |
commit | 23c863bbdcf3ad050a8e1542030c85d668d10405 (patch) | |
tree | c8ab381fcac644fc51668b998a6474d8f29c2efe /hcid | |
parent | a8181a256a25ec21661d9bf8b4248d1c69962f76 (diff) |
Fixed memory leak and added address check
Diffstat (limited to 'hcid')
-rw-r--r-- | hcid/adapter.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c index 803c2f17..860b01c7 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -233,8 +233,7 @@ int pending_remote_name_cancel(struct adapter *adapter) static void device_agent_removed(struct agent *agent, struct device *device) { - if (device->agent == agent) - device->agent = NULL; + device->agent = NULL; } static struct bonding_request_info *bonding_request_new(DBusConnection *conn, @@ -246,11 +245,6 @@ static struct bonding_request_info *bonding_request_new(DBusConnection *conn, struct bonding_request_info *bonding; struct device *device; - bonding = g_new0(struct bonding_request_info, 1); - - bonding->conn = dbus_connection_ref(conn); - bonding->msg = dbus_message_ref(msg); - if (hcid_dbus_use_experimental()) { device = adapter_get_device(conn, adapter, address); if (!device) @@ -265,6 +259,11 @@ static struct bonding_request_info *bonding_request_new(DBusConnection *conn, device); } + bonding = g_new0(struct bonding_request_info, 1); + + bonding->conn = dbus_connection_ref(conn); + bonding->msg = dbus_message_ref(msg); + str2ba(address, &bonding->bdaddr); return bonding; @@ -3789,6 +3788,9 @@ static DBusHandlerResult create_paired_device(DBusConnection *conn, DBUS_TYPE_INVALID) == FALSE) return error_invalid_arguments(conn, msg, NULL); + if (check_address(address) < 0) + return error_invalid_arguments(conn, msg, NULL); + return create_bonding(conn, msg, address, agent_path, data); } @@ -3859,8 +3861,7 @@ static DBusHandlerResult find_device(DBusConnection *conn, static void agent_removed(struct agent *agent, struct adapter *adapter) { - if (adapter->agent == agent) - adapter->agent = NULL; + adapter->agent = NULL; } static DBusHandlerResult register_agent(DBusConnection *conn, |