From 896eec37b2952219a27c7f747931a2fcdab2ac3e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 2 Feb 2010 14:03:36 -0800 Subject: [PATCH] stp: Fix memory leak. Found with valgrind. --- lib/stp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/stp.c b/lib/stp.c index cf1b2f98..6fad3a08 100644 --- a/lib/stp.c +++ b/lib/stp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -256,7 +256,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. */ -- 2.30.2