From: Tycho Andersen Date: Mon, 10 Feb 2020 15:14:33 +0000 (-0700) Subject: lxclock: fix a small memory leak X-Git-Tag: lxc-4.0.0~53^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8a6a00cc385fc0c6f36c6497f03a3fd40059706;p=thirdparty%2Flxc.git lxclock: fix a small memory leak if (!name), we allocate an unnamed semaphore, but if we then fail to allocate/create the lock, we don't free this semaphore, and we just leak it. Signed-off-by: Tycho Andersen --- diff --git a/src/lxc/lxclock.c b/src/lxc/lxclock.c index a77951a5b..318e5bf5a 100644 --- a/src/lxc/lxclock.c +++ b/src/lxc/lxclock.c @@ -169,6 +169,8 @@ struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name) l->type = LXC_LOCK_FLOCK; l->u.f.fname = lxclock_name(lxcpath, name); if (!l->u.f.fname) { + if (!name) + free(l->u.sem); free(l); l = NULL; goto on_error;