[systemd-devel] [PATCH 2/2] libsystemd-network : Fix resource leaks in test-lldp

Philippe De Swert philippedeswert at gmail.com
Wed Dec 31 06:16:03 PST 2014


Fix some resources leaks in test-lldp found with coverity:
CID#1261388, CID#1261385, CID#1261383
---
 src/libsystemd-network/test-lldp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/libsystemd-network/test-lldp.c b/src/libsystemd-network/test-lldp.c
index e9d5d7b..5f9eba3 100644
--- a/src/libsystemd-network/test-lldp.c
+++ b/src/libsystemd-network/test-lldp.c
@@ -131,7 +131,8 @@ static int lldp_parse_chassis_tlv(tlv_packet *m, uint8_t *type) {
 }
 
 static int lldp_parse_port_id_tlv(tlv_packet *m) {
-        char *str = NULL, *p;
+        char *str = NULL;
+        _cleanup_free_ char *p;
         uint16_t length;
         uint8_t subtype;
 
@@ -158,7 +159,7 @@ static int lldp_parse_port_id_tlv(tlv_packet *m) {
 }
 
 static int lldp_parse_system_name_tlv(tlv_packet *m) {
-        char *str = NULL, *p;
+        _cleanup_free_ char *str = NULL, *p;
         uint16_t length;
 
         assert_se(lldp_tlv_packet_enter_container(m, LLDP_TYPE_SYSTEM_NAME) >= 0);
@@ -175,7 +176,7 @@ static int lldp_parse_system_name_tlv(tlv_packet *m) {
 }
 
 static int lldp_parse_system_desc_tlv(tlv_packet *m) {
-        char *str = NULL, *p;
+        _cleanup_free_ char *str = NULL, *p;
         uint16_t length;
 
         assert_se(lldp_tlv_packet_enter_container(m, LLDP_TYPE_SYSTEM_DESCRIPTION) >= 0);
-- 
2.1.3



More information about the systemd-devel mailing list