[PATCH] bluez-libs leak

"Claudio Takahasi" <[email protected]>
Newsgroups gmane.linux.bluez.devel
Message-ID <[email protected]>
Hi Marcel,

I found a small leak. Please review the patch.

run valgrind sdptool browse xx:xx:xx:xx:xx:xx to see the leak.

Regards,
Claudio.
-- 
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
leak01.patch (text/x-diff, 886 B)
Index: src/sdp.c
===================================================================
RCS file: /cvsroot/bluez/libs/src/sdp.c,v
retrieving revision 1.81
diff -u -r1.81 sdp.c
--- src/sdp.c	5 Mar 2008 19:30:32 -0000	1.81
+++ src/sdp.c	7 Mar 2008 21:07:42 -0000
@@ -1530,13 +1530,14 @@
 	if (sdpdata && sdpdata->dtd >= SDP_SEQ8 && sdpdata->dtd <= SDP_SEQ32) {
 		sdp_data_t *d;
 		for (d = sdpdata->val.dataseq; d; d = d->next) {
-			uuid_t *u = malloc(sizeof(uuid_t));
-			memset((char *)u, 0, sizeof(uuid_t));
-			if (d->dtd >= SDP_UUID16 && d->dtd <= SDP_UUID128) {
-			  	*u = d->val.uuid;
-			  	*seqp = sdp_list_append(*seqp, u);
-			} else
+			uuid_t *u;
+			if (d->dtd < SDP_UUID16 || d->dtd > SDP_UUID128)
 				goto fail;
+
+			u = malloc(sizeof(uuid_t));
+			memset((char *)u, 0, sizeof(uuid_t));
+			*u = d->val.uuid;
+			*seqp = sdp_list_append(*seqp, u);
 		}
 		return 0;
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.