From: Vincent Bernat Date: Sat, 22 Aug 2015 21:13:54 +0000 (+0200) Subject: lldpd: fix a memory leak in the way interfaces were cloned X-Git-Tag: 0.8.0~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c31f0d8ad9251490d78cf89401e34e9d293524b1;p=thirdparty%2Flldpd.git lldpd: fix a memory leak in the way interfaces were cloned --- 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 *