commands_utils: auto free lxc_add_state_client

parent b02dc0d9
......@@ -191,9 +191,9 @@ int lxc_cmd_connect(const char *name, const char *lxcpath,
int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
lxc_state_t states[MAX_STATE])
{
__do_free struct lxc_state_client *newclient = NULL;
__do_free struct lxc_list *tmplist = NULL;
int state;
struct lxc_state_client *newclient;
struct lxc_list *tmplist;
newclient = malloc(sizeof(*newclient));
if (!newclient)
......@@ -204,21 +204,19 @@ int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
newclient->clientfd = state_client_fd;
tmplist = malloc(sizeof(*tmplist));
if (!tmplist) {
free(newclient);
if (!tmplist)
return -ENOMEM;
}
state = handler->state;
if (states[state] != 1) {
lxc_list_add_elem(tmplist, newclient);
lxc_list_add_tail(&handler->conf->state_clients, tmplist);
} else {
free(newclient);
free(tmplist);
return state;
}
TRACE("Added state client %d to state client list", state_client_fd);
move_ptr(newclient);
move_ptr(tmplist);
return MAX_STATE;
}
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