From 8ecd7f2fa168fc4d06712d91f3dec42468111382 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Mon, 10 Feb 2020 08:14:33 -0700 Subject: [PATCH] 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 --- src/lxc/lxclock.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lxc/lxclock.c b/src/lxc/lxclock.c index a77951a5b4..318e5bf5a3 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;