From: Vincent Bernat Date: Wed, 18 Nov 2009 06:20:35 +0000 (+0100) Subject: Don't free statically allocated port. X-Git-Tag: 0.4.2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=65727e4a8f232b5536de0d93ce19fb51c9ba9fb2;p=thirdparty%2Flldpd.git Don't free statically allocated port. This is a backport of [4e624dc2f10a821221a4497f564371d12b229aa2]. This fixes ticket #26 in 0.4.x. --- diff --git a/src/cdp.c b/src/cdp.c index 95cb6c87..608d58d6 100644 --- a/src/cdp.c +++ b/src/cdp.c @@ -463,6 +463,7 @@ cdp_decode(struct lldpd *cfg, char *frame, int s, malformed: lldpd_chassis_cleanup(chassis); lldpd_port_cleanup(port, 1); + free(port); return -1; } diff --git a/src/edp.c b/src/edp.c index c3f02fee..fc0bd961 100644 --- a/src/edp.c +++ b/src/edp.c @@ -477,6 +477,7 @@ edp_decode(struct lldpd *cfg, char *frame, int s, malformed: lldpd_chassis_cleanup(chassis); lldpd_port_cleanup(port, 1); + free(port); return -1; } diff --git a/src/lldp.c b/src/lldp.c index 878a8dcd..6a7da3e6 100644 --- a/src/lldp.c +++ b/src/lldp.c @@ -789,5 +789,6 @@ lldp_decode(struct lldpd *cfg, char *frame, int s, malformed: lldpd_chassis_cleanup(chassis); lldpd_port_cleanup(port, 1); + free(port); return -1; } diff --git a/src/lldpd.c b/src/lldpd.c index 2c9e1c53..f85227a7 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -366,8 +366,7 @@ lldpd_vlan_cleanup(struct lldpd_port *port) #endif /* If `all' is true, clear all information, including information that - are not refreshed periodically. If `all' is true, also free the - port. */ + are not refreshed periodically. Port should be freed manually. */ void lldpd_port_cleanup(struct lldpd_port *port, int all) { @@ -382,8 +381,6 @@ lldpd_port_cleanup(struct lldpd_port *port, int all) #endif free(port->p_id); free(port->p_descr); - if (all) - free(port); } void @@ -409,6 +406,7 @@ lldpd_remote_cleanup(struct lldpd *cfg, struct lldpd_hardware *hardware, int res { if (hardware->h_rport != NULL) { lldpd_port_cleanup(hardware->h_rport, 1); + free(hardware->h_rport); hardware->h_rport = NULL; } if (hardware->h_rchassis != NULL) { @@ -982,6 +980,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s, cleanup: lldpd_chassis_cleanup(chassis); lldpd_port_cleanup(port, 1); + free(port); return; } diff --git a/src/sonmp.c b/src/sonmp.c index e55b8fda..58b7cb0b 100644 --- a/src/sonmp.c +++ b/src/sonmp.c @@ -376,6 +376,7 @@ sonmp_decode(struct lldpd *cfg, char *frame, int s, malformed: lldpd_chassis_cleanup(chassis); lldpd_port_cleanup(port, 1); + free(port); return -1; }