[PATCH BlueZ v2 3/4] sdp: Fix memory leak when freeing alternates
Luiz Augusto von Dentz <[email protected]>
| Newsgroups | org.kernel.vger.linux-bluetooth |
|---|---|
| Message-ID | <[email protected]> |
From: Luiz Augusto von Dentz <[email protected]> sdp_data_alloc_with_length() stores the members of SDP_ALT8, SDP_ALT16 and SDP_ALT32 in val.dataseq, exactly like it does for the SDP_SEQ8, SDP_SEQ16 and SDP_SEQ32 sequences. sdp_data_free() only calls data_seq_free() for the sequences though, so freeing an alternate frees the alternate itself and leaks every one of its members, along with anything they own in turn: 209 (48 direct, 161 indirect) bytes in 1 blocks are definitely lost at calloc (vg_replace_malloc.c:1678) by sdp_data_alloc_with_length (sdp.c:350) by sdp_data_alloc (sdp.c:486) by sdp_xml_parse_int (sdp-xml.c:243) by sdp_xml_parse_datatype (sdp-xml.c:421) by element_start (sdp-xml.c:507) Free the members of alternates as well. Assisted-by: Claude:claude-opus-5 --- lib/bluetooth/sdp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/bluetooth/sdp.c b/lib/bluetooth/sdp.c index 8c0865398519..1e027f9ebe6d 100644 --- a/lib/bluetooth/sdp.c +++ b/lib/bluetooth/sdp.c @@ -972,6 +972,9 @@ void sdp_data_free(sdp_data_t *d) case SDP_SEQ8: case SDP_SEQ16: case SDP_SEQ32: + case SDP_ALT8: + case SDP_ALT16: + case SDP_ALT32: data_seq_free(d); break; case SDP_URL_STR8: -- 2.54.0