Skip to contentSkip to conversation

hw/bt/sdp: Fix resource leak detect by coverity

PATCH In review Shannon Zhao 2 participants 3 messages Mar 14, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/bt/sdp: Fix resource leak detect by coverity

Free data in function sdp_attr_write after use.

---
 hw/bt/sdp.c | 1 +
 1 file changed, 1 insertion(+)
hw/bt/sdp.c +1 -0
index 218e075..8e6d5e3 100644
@@ -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(data);
 
     /* Sort the attribute list by the AttributeID */
     qsort(record->attribute_list, record->attributes,
Signature · 1 line
1.8.3.1
#1 lore raw

Am 14.03.2015 um 04:42 schrieb Shannon Zhao:

Quoted 13 lines

Free data in function sdp_attr_write after use.

---
  hw/bt/sdp.c | 1 +
  1 file changed, 1 insertion(+)
hw/bt/sdp.c +0 -0
index 218e075..8e6d5e3 100644

hw/bt/sdp.c static void sdp_service_record_build(struct sdp_service_record_s *record, · line 738

Quoted 4 lines
hw/bt/sdp.c +1 -0
@@ -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(data);

No, here more work is needed. data is no longer the original data, because two lines above it is modified.

Quoted 3 lines
hw/bt/sdp.c +0 -0
      /* Sort the attribute list by the AttributeID */
      qsort(record->attribute_list, record->attributes,
#2 lore raw
Quoted 9 lines · Stefan Weil

Am 14.03.2015 um 04:42 schrieb Shannon Zhao:

Quoted 8 lines

Free data in function sdp_attr_write after use.

---
  hw/bt/sdp.c | 1 +
  1 file changed, 1 insertion(+)
Quoted 12 lines

hw/bt/sdp.c static void sdp_service_record_build(struct sdp_service_record_s *record, · line 738

Quoted 9 lines
hw/bt/sdp.c +1 -0
index 218e075..8e6d5e3 100644
@@ -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(data);

No, here more work is needed. data is no longer the original data, because two lines above it is modified.

Thanks for pointing out.

Quoted 7 lines

hw/bt/sdp.c static void sdp_service_record_build(struct sdp_service_record_s *record, · line 741

Quoted 3 lines
hw/bt/sdp.c +0 -0
        /* Sort the attribute list by the AttributeID */
      qsort(record->attribute_list, record->attributes,

.