X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstp.c;h=38885c07f666e472ce4691988863e7df7879e991;hb=3bcf3e33e9cfb7fd837086bfa8e627110d84dce8;hp=5d35156acb7ccef49e2be0f097fbc1a691ff4f3a;hpb=7f3adc00f8d9cc0e035cd58817a28301e62eaec8;p=openvswitch diff --git a/lib/stp.c b/lib/stp.c index 5d35156a..38885c07 100644 --- a/lib/stp.c +++ b/lib/stp.c @@ -216,7 +216,7 @@ stp_create(const char *name, stp_identifier bridge_id, struct stp *stp; struct stp_port *p; - stp = xcalloc(1, sizeof *stp); + stp = xzalloc(sizeof *stp); stp->name = xstrdup(name); stp->bridge_id = bridge_id; if (!(stp->bridge_id >> 48)) { @@ -258,7 +258,10 @@ stp_create(const char *name, stp_identifier bridge_id, void stp_destroy(struct stp *stp) { - free(stp); + if (stp) { + free(stp->name); + free(stp); + } } /* Runs 'stp' given that 'ms' milliseconds have passed. */