hw/bt/sdp.c:753:5: warning: Potential leak of memory pointed to by 'data' qsort(record->attribute_list, record->attributes, ^~~~~
Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- hw/bt/*: get_maintainer.pl: No maintainers found hw/bt/sdp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/bt/sdp.c b/hw/bt/sdp.c index f67b3b89c0..7b2186e1f4 100644 --- a/hw/bt/sdp.c +++ b/hw/bt/sdp.c @@ -711,7 +711,7 @@ static void sdp_service_record_build(struct sdp_service_record_s *record, struct sdp_def_service_s *def, int handle) { int len = 0; - uint8_t *data; + uint8_t *buf, *data; int *uuid; record->uuids = 0; @@ -725,7 +725,8 @@ static void sdp_service_record_build(struct sdp_service_record_s *record, g_malloc0(record->attributes * sizeof(*record->attribute_list)); record->uuid = g_malloc0(record->uuids * sizeof(*record->uuid)); - data = g_malloc(len); + buf = g_malloc(len); + data = buf; record->attributes = 0; uuid = record->uuid; @@ -748,6 +749,7 @@ static void sdp_service_record_build(struct sdp_service_record_s *record, record->attribute_list[record->attributes ++].len = len; data += len; } + g_free(buf); /* Sort the attribute list by the AttributeID */ qsort(record->attribute_list, record->attributes, -- 2.13.3