Commit 41c3b7c7 by Dwight Engen Committed by Serge Hallyn

valgrind: fix memory leak on container new/put

parent 75b55352
...@@ -122,6 +122,10 @@ struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name) ...@@ -122,6 +122,10 @@ struct lxc_lock *lxc_newlock(const char *lxcpath, const char *name)
if (!name) { if (!name) {
l->type = LXC_LOCK_ANON_SEM; l->type = LXC_LOCK_ANON_SEM;
l->u.sem = lxc_new_unnamed_sem(); l->u.sem = lxc_new_unnamed_sem();
if (!l->u.sem) {
free(l);
l = NULL;
}
goto out; goto out;
} }
...@@ -248,8 +252,11 @@ void lxc_putlock(struct lxc_lock *l) ...@@ -248,8 +252,11 @@ void lxc_putlock(struct lxc_lock *l)
return; return;
switch(l->type) { switch(l->type) {
case LXC_LOCK_ANON_SEM: case LXC_LOCK_ANON_SEM:
if (l->u.sem) if (l->u.sem) {
sem_close(l->u.sem); sem_close(l->u.sem);
free(l->u.sem);
l->u.sem = NULL;
}
break; break;
case LXC_LOCK_FLOCK: case LXC_LOCK_FLOCK:
process_lock(); process_lock();
...@@ -264,6 +271,7 @@ void lxc_putlock(struct lxc_lock *l) ...@@ -264,6 +271,7 @@ void lxc_putlock(struct lxc_lock *l)
} }
break; break;
} }
free(l);
} }
int process_lock(void) int process_lock(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment