Skip to content

Commit

Permalink
lxclock: fix a small memory leak
Browse files Browse the repository at this point in the history
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 <tycho@tycho.ws>
  • Loading branch information
tych0 authored and Christian Brauner committed Mar 2, 2020
1 parent a4922b6 commit 8ecd7f2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lxc/lxclock.c
Expand Up @@ -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;
Expand Down

0 comments on commit 8ecd7f2

Please sign in to comment.