libsemanage: genhomedircon: do not leak on failure in write_gen_home_dir_context

We generate a list of users, but we do not free that list on error.
Just keep popping and freeing them on error.

Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Eric Paris 2013-02-05 14:09:52 -05:00
parent 06f2a7c3a9
commit 7d83d86ba1

View File

@ -934,16 +934,21 @@ static int write_gen_home_dir_context(genhomedircon_settings_t * s, FILE * out,
if (write_home_dir_context(s, out, homedir_context_tpl,
users->name,
users->sename, users->home,
users->prefix, users->level)) {
return STATUS_ERR;
}
users->prefix, users->level))
goto err;
if (write_user_context(s, out, user_context_tpl, users->name,
users->sename, users->prefix)) {
return STATUS_ERR;
}
users->sename, users->prefix))
goto err;
}
return STATUS_SUCCESS;
err:
for (; users; pop_user_entry(&users)) {
/* the pop function takes care of all the cleanup
* so the loop body is just empty */
}
return STATUS_ERR;
}
/**