Memory leak in sdptool
"Cidorvan Leite" <[email protected]>
| Newsgroups | gmane.linux.bluez.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello! There are a lot of memory leaks in sdptool when adding local services. The patch attached fixes wiimote local service. This is not a critical problem because sdptool closes after the service added and all memory is released. However, with this fix, sdptool can be used like examples for other sdp applications without memory leak. So, is that a good idea to fix all local service? ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Bluez-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/bluez-devel
leak.diff
(text/x-patch, 1.9 KB)
Index: sdptool.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/sdptool.c,v
retrieving revision 1.72
diff -u -p -r1.72 sdptool.c
--- sdptool.c 2 Feb 2008 03:37:54 -0000 1.72
+++ sdptool.c 23 Apr 2008 14:28:38 -0000
@@ -2304,15 +2304,18 @@ static int add_hid_wiimote(sdp_session_t
sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
root = sdp_list_append(NULL, &root_uuid);
sdp_set_browse_groups(&record, root);
+ sdp_list_free(root, NULL);
sdp_uuid16_create(&hid_uuid, HID_SVCLASS_ID);
svclass_id = sdp_list_append(NULL, &hid_uuid);
sdp_set_service_classes(&record, svclass_id);
+ sdp_list_free(svclass_id, NULL);
sdp_uuid16_create(&profile[0].uuid, HID_PROFILE_ID);
profile[0].version = 0x0100;
pfseq = sdp_list_append(NULL, profile);
sdp_set_profile_descs(&record, pfseq);
+ sdp_list_free(pfseq, NULL);
sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
proto[1] = sdp_list_append(0, &l2cap_uuid);
@@ -2326,6 +2329,11 @@ static int add_hid_wiimote(sdp_session_t
aproto = sdp_list_append(0, apseq);
sdp_set_access_protos(&record, aproto);
+ sdp_data_free(psm);
+ sdp_list_free(proto[2], NULL);
+ sdp_list_free(proto[1], NULL);
+ sdp_list_free(apseq, NULL);
+ sdp_list_free(aproto, NULL);
proto[1] = sdp_list_append(0, &l2cap_uuid);
psm = sdp_data_alloc(SDP_UINT16, &intr);
@@ -2338,6 +2346,11 @@ static int add_hid_wiimote(sdp_session_t
aproto = sdp_list_append(0, apseq);
sdp_set_add_access_protos(&record, aproto);
+ sdp_data_free(psm);
+ sdp_list_free(proto[2], NULL);
+ sdp_list_free(proto[1], NULL);
+ sdp_list_free(apseq, NULL);
+ sdp_list_free(aproto, NULL);
add_lang_attr(&record);
@@ -2407,6 +2420,9 @@ static int add_hid_wiimote(sdp_session_t
return -1;
}
+ sdp_list_free(record.pattern, free);
+ sdp_list_free(record.attrlist, (sdp_free_func_t)sdp_data_free);
+
printf("Wii-Mote service registered\n");
return 0;