policycoreutils: free memory of allocated context in run_init

Found by scan-build.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
Christian Göttsche 2021-07-14 20:13:42 +02:00 committed by James Carter
parent d8b9bd5c2a
commit f0c354afc0

View file

@ -406,14 +406,19 @@ int main(int argc, char *argv[])
if (chdir("/")) {
perror("chdir");
free(new_context);
exit(-1);
}
if (setexeccon(new_context) < 0) {
fprintf(stderr, _("Could not set exec context to %s.\n"),
new_context);
free(new_context);
exit(-1);
}
free(new_context);
if (access("/usr/sbin/open_init_pty", X_OK) != 0) {
if (execvp(argv[1], argv + 1)) {
perror("execvp");