diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2010-11-10 19:56:00 -0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2010-11-11 12:09:21 +0200 |
commit | 1c00d839375478e39ea4dea360ee9f8b700ccbda (patch) | |
tree | 3d6fea14646707717258742ab5bc301a7614c955 /src | |
parent | 34d052348edbba20d5583b0393579a74c43d6cb0 (diff) | |
download | bluez-1c00d839375478e39ea4dea360ee9f8b700ccbda.tar.gz |
Fix possible memory leak of the GIOChannel in the attribute server
Diffstat (limited to 'src')
-rw-r--r-- | src/attrib-server.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/attrib-server.c b/src/attrib-server.c index 1fc1c18f1..f64409140 100644 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -609,6 +609,20 @@ int attrib_server_init(void) return -1; } + record = server_record_new(); + if (record == NULL) { + error("Unable to create GATT service record"); + goto failed; + } + + if (add_record_to_server(BDADDR_ANY, record) < 0) { + error("Failed to register GATT service record"); + sdp_record_free(record); + goto failed; + } + + sdp_handle = record->handle; + /* LE socket */ le_io = bt_io_listen(BT_IO_L2CAP, NULL, confirm_event, NULL, NULL, &gerr, @@ -623,21 +637,13 @@ int attrib_server_init(void) /* Doesn't have LE support, continue */ } - record = server_record_new(); - if (record == NULL) { - error("Unable to create GATT service record"); - return -1; - } - - if (add_record_to_server(BDADDR_ANY, record) < 0) { - error("Failed to register GATT service record"); - sdp_record_free(record); - return -1; - } + return 0; - sdp_handle = record->handle; +failed: + g_io_channel_unref(l2cap_io); + l2cap_io = NULL; - return 0; + return -1; } void attrib_server_exit(void) |