diff options
author | Tom Gundersen <teg@jklm.no> | 2014-10-29 19:44:55 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-10-29 19:44:55 +0100 |
commit | f84d316afe14ea97ca5340e46124cff9f061b7b0 (patch) | |
tree | d5fbaa96d9b3df6287d88c5d5355b6ac8dced35c | |
parent | e3178632635a922cba17fea3b74b6a620d3acdd8 (diff) |
lldp: tlv - *_free() functions should always succeedlldp
In particular, it should be ok to pass in a NULL argument (just as it is to free()).
Also, don't wrap free() in another function, but call free() directly.
With the asserts the tests don't pass.
-rw-r--r-- | src/libsystemd-network/lldp-tlv.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c index 2c8f79821..78294e49d 100644 --- a/src/libsystemd-network/lldp-tlv.c +++ b/src/libsystemd-network/lldp-tlv.c @@ -37,13 +37,6 @@ int tlv_section_new(tlv_section **ret) { return 0; } -void tlv_section_free(tlv_section *m) { - - assert(m); - - free(m); -} - int tlv_packet_new(tlv_packet **ret) { tlv_packet *m; @@ -61,10 +54,11 @@ int tlv_packet_new(tlv_packet **ret) { void tlv_packet_free(tlv_packet *m) { tlv_section *s, *n; - assert(m); + if (!m) + return; LIST_FOREACH_SAFE(section, s, n, m->sections) - tlv_section_free(n); + free(n); free(m); } @@ -270,7 +264,7 @@ int tlv_packet_parse_pdu(tlv_packet *m, uint16_t size) { section->length = ntohs(t) & 0x01ff; if(section->type == LLDP_TYPE_END || section->type >=_LLDP_TYPE_MAX) { - tlv_section_free(section); + free(section); break; } |