From: Dwight Engen Date: Wed, 4 Sep 2013 21:04:51 +0000 (-0400) Subject: valgrind: fix memory leak on container new/put X-Git-Tag: lxc-1.0.0.alpha1~1^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41c3b7c7ac9b33bc562ebad9ea124912577f2ba5;p=thirdparty%2Flxc.git valgrind: fix memory leak on container new/put Signed-off-by: Dwight Engen Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/lxclock.c b/src/lxc/lxclock.c index dea694183..79ebf84a7 100644 --- a/src/lxc/lxclock.c +++ b/src/lxc/lxclock.c @@ -122,6 +122,10 @@ struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name) if (!name) { l->type = LXC_LOCK_ANON_SEM; l->u.sem = lxc_new_unnamed_sem(); + if (!l->u.sem) { + free(l); + l = NULL; + } goto out; } @@ -248,8 +252,11 @@ void lxc_putlock(struct lxc_lock *l) return; switch(l->type) { case LXC_LOCK_ANON_SEM: - if (l->u.sem) + if (l->u.sem) { sem_close(l->u.sem); + free(l->u.sem); + l->u.sem = NULL; + } break; case LXC_LOCK_FLOCK: process_lock(); @@ -264,6 +271,7 @@ void lxc_putlock(struct lxc_lock *l) } break; } + free(l); } int process_lock(void)