]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Don't free statically allocated port.
authorVincent Bernat <bernat@luffy.cx>
Wed, 18 Nov 2009 06:20:35 +0000 (07:20 +0100)
committerVincent Bernat <bernat@luffy.cx>
Wed, 18 Nov 2009 06:20:35 +0000 (07:20 +0100)
This is a backport of [4e624dc2f10a821221a4497f564371d12b229aa2]. This
fixes ticket #26 in 0.4.x.

src/cdp.c
src/edp.c
src/lldp.c
src/lldpd.c
src/sonmp.c

index 95cb6c876bba91ac0a90fd3f794241e7156c72a8..608d58d68e5ebea0c3049e52b1750f8730566be7 100644 (file)
--- 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;
 }
 
index c3f02fee291f9c01246942d164b14066cf2b382a..fc0bd961514ec0ef68e3bce1b9fd3619248f14a4 100644 (file)
--- 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;
 }
 
index 878a8dcd3237788b7f29e90f4b951e4073ac04d3..6a7da3e6245fe69dda02f537c07a70ab42f764d9 100644 (file)
@@ -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;
 }
index 2c9e1c534751d7fb466bc5c5011b05c8cb560254..f85227a749537145b60d6db99bf97bcb3361b849 100644 (file)
@@ -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;
 }
 
index e55b8fda3fa060b1ef0f5322cc66d7289a0177cf..58b7cb0b5afd421ba273dc5bd804fbd9c460f697 100644 (file)
@@ -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;
 }