2012-02-07 09:33:10

by Santiago Carot

[permalink] [raw]
Subject: [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels

Channel is not being released when the channel is attached over
an uninitialized GATT server.
---
src/attrib-server.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 2995167..a23d5d2 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -1020,8 +1020,14 @@ guint attrib_channel_attach(GAttrib *attrib, gboolean out)
}

server = find_gatt_server(&channel->src);
- if (server == NULL)
+ if (server == NULL) {
+ char src[18];
+
+ ba2str(&channel->src, src);
+ error("Not GATT server found in %s", src);
+ g_free(channel);
return 0;
+ }

channel->server = server;

--
1.7.9



2012-02-07 09:33:11

by Santiago Carot

[permalink] [raw]
Subject: [PATCH 2/2] attrib-server: Fix bad error message

---
src/attrib-server.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index a23d5d2..3d4634f 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -171,7 +171,7 @@ static struct gatt_server *find_gatt_server(const bdaddr_t *bdaddr)
char addr[18];

ba2str(bdaddr, addr);
- error("Not GATT adapter found for address %s", addr);
+ error("Not GATT server found in %s", addr);
return NULL;
}

--
1.7.9