[systemd-devel] [PATCH 2/2] libsystemd-network : Fix resource leaks in test-lldp
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Thu Jan 1 06:18:03 PST 2015
On Wed, Dec 31, 2014 at 04:16:03PM +0200, Philippe De Swert wrote:
> 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);
David pushed some fixes to this code yesterday, but it is all unnecessary imo.
Could you update your patch to use strncmp() and kill all the useless
string copying?
Zbyszek
More information about the systemd-devel
mailing list