Skip to contentSkip to conversation

bluez-libs leak

PATCH New Claudio Takahasi 1 participant 1 message Mar 7, 2008 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bluez-libs leak

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.

Signature · 3 lines
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

Index: src/sdp.c
===================================================================
RCS file: /cvsroot/bluez/libs/src/sdp.c,v
retrieving revision 1.81

sdp.c +7 -6
diff -u -r1.81 sdp.c
@@ -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;
 	}

-------------------------------------------------------------------------
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