Free data in function sdp_attr_write after use. Signed-off-by: Shannon Zhao <zhaoshengl...@huawei.com> Signed-off-by: Shannon Zhao <shannon.z...@linaro.org> --- For minimum modification, just add a variable to record the data. --- hw/bt/sdp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/bt/sdp.c b/hw/bt/sdp.c index 218e075..8be0d14 100644 --- a/hw/bt/sdp.c +++ b/hw/bt/sdp.c @@ -698,7 +698,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 *data, *pt; int *uuid; record->uuids = 0; @@ -712,7 +712,7 @@ 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); + pt = data = g_malloc(len); record->attributes = 0; uuid = record->uuid; @@ -735,6 +735,7 @@ static void sdp_service_record_build(struct sdp_service_record_s *record, record->attribute_list[record->attributes ++].len = len; data += len; } + g_free(pt); /* Sort the attribute list by the AttributeID */ qsort(record->attribute_list, record->attributes, -- 1.8.3.1