]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxclock: fix a small memory leak 3264/head
authorTycho Andersen <tycho@tycho.ws>
Mon, 10 Feb 2020 15:14:33 +0000 (08:14 -0700)
committerTycho Andersen <tycho@tycho.ws>
Mon, 10 Feb 2020 15:14:33 +0000 (08:14 -0700)
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>
src/lxc/lxclock.c

index a77951a5b4d74fab9bd133f756759eb5d0ed87d7..318e5bf5a32afa58b1f1411ec0de91f643be4041 100644 (file)
@@ -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;