2013-01-04 05:42:27

by Jaganath Kanakkassery

[permalink] [raw]
Subject: [PATCH 1/2] storage: Fix memory leak

If bt_uuid2string() returns NULL then svcclass has to be freed
---
src/storage.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/storage.c b/src/storage.c
index 375974a..be3bbf2 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -180,8 +180,10 @@ sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid)

/* Extract the uuid */
uuid_str = bt_uuid2string(svcclass->data);
- if (!uuid_str)
+ if (!uuid_str) {
+ sdp_list_free(svcclass, free);
continue;
+ }

if (!strcasecmp(uuid_str, uuid)) {
sdp_list_free(svcclass, free);
--
1.7.9.5



2013-01-04 14:17:22

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/2] storage: Fix memory leak

Hi Jaganath,

On Fri, Jan 04, 2013, Jaganath Kanakkassery wrote:
> If bt_uuid2string() returns NULL then svcclass has to be freed
> ---
> src/storage.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)

Both patches have been applied. Thanks.

Johan

2013-01-04 05:42:28

by Jaganath Kanakkassery

[permalink] [raw]
Subject: [PATCH 2/2] rfkill: Fix count parameter in read

Since g_str_has_prefix() has been used with the output buffer of read
it should be NULL terminated
---
src/rfkill.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rfkill.c b/src/rfkill.c
index bac9efd..51591cb 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -114,7 +114,7 @@ static gboolean rfkill_event(GIOChannel *chan,

memset(sysname, 0, sizeof(sysname));

- if (read(fd, sysname, sizeof(sysname)) < 4) {
+ if (read(fd, sysname, sizeof(sysname) - 1) < 4) {
close(fd);
return TRUE;
}
--
1.7.9.5