2006-06-07 15:12:45

by Robert Wlaschin

[permalink] [raw]
Subject: Re: [Bluez-devel] rfcomm (utils)

Thanks for the quick response.

In reference, the current CVS available
http://bluez.cvs.sourceforge.net/bluez/ web site seems to have the same
issue.

Here's a suggested patch (using the 2.25 source)

--- bluez-utils-2.25/rfcomm/main.c.orig 2006-06-07 08:01:03.149584500
-0700
+++ bluez-utils-2.25/rfcomm/main.c.new 2006-06-07 08:02:25.915739200
-0700
@@ -132,11 +132,14 @@

if (ioctl(ctl, RFCOMMGETDEVLIST, (void *) dl) < 0) {
perror("Can't get device list");
+ free(dl);
exit(1);
}

for (i = 0; i < dl->dev_num; i++)
print_dev_info(di + i);
+
+ free(dl);
}

static int create_dev(int ctl, int dev, uint32_t flags, bdaddr_t
*bdaddr, int argc, char **argv)
@@ -237,12 +240,15 @@

if (ioctl(ctl, RFCOMMGETDEVLIST, (void *) dl) < 0) {
perror("Can't get device list");
+ free(dl);
exit(1);
}

for (i = 0; i < dl->dev_num; i++)
release_dev(ctl, (di + i)->id, 0);

+ free(dl);
+
return 0;
}


This should catch the missing deallocs.

Hope this helps.

Thanks,
Robert

Hi Robert,

> In poking around in \bluez-utils-2.21\rfcomm\main.c, I noticed in
> several functions (including print_dev_list) there seems to be a
malloc
> statement but no corresponding free. Is this the recommended way to
> handle the rfcomm_dev_list_req structures?

this seems to be a bug, but I would prefer you actually check the latest
version from CVS instead of an old package and be more specific of the
cases you are talking about. Otherwise we can fix them.

Regards

Marcel




_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel