From c31f0d8ad9251490d78cf89401e34e9d293524b1 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 22 Aug 2015 23:13:54 +0200 Subject: [PATCH] lldpd: fix a memory leak in the way interfaces were cloned --- src/daemon/lldpd.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index 59fa4569..c4f8c6fe 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -177,10 +177,12 @@ lldpd_clone_port(struct lldpd_port *destination, struct lldpd_port *source) if (output_len == -1 || lldpd_port_unserialize(output, output_len, &cloned) <= 0) { log_warnx("alloc", "unable to clone default port"); - goto end; + free(output); + return -1; } memcpy(destination, cloned, sizeof(struct lldpd_port)); - free(cloned); cloned = NULL; + free(cloned); + free(output); #ifdef ENABLE_DOT1 marshal_repair_tailq(lldpd_vlan, &destination->p_vlans, v_entries); marshal_repair_tailq(lldpd_ppvid, &destination->p_ppvids, p_entries); @@ -190,11 +192,6 @@ lldpd_clone_port(struct lldpd_port *destination, struct lldpd_port *source) marshal_repair_tailq(lldpd_custom, &destination->p_custom_list, next); #endif return 0; - -end: - free(output); - if (cloned != NULL) lldpd_port_cleanup(cloned, 1); - return -1; } struct lldpd_hardware * -- 2.39.5