qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] hw/bt/sdp: Fix resource leak detect by coverity


From: Shannon Zhao
Subject: [Qemu-devel] [PATCH] hw/bt/sdp: Fix resource leak detect by coverity
Date: Sat, 14 Mar 2015 17:47:34 +0800

Free data in function sdp_attr_write after use.

Signed-off-by: Shannon Zhao <address@hidden>
Signed-off-by: Shannon Zhao <address@hidden>
---
    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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]