setpriv: fix memory leak in local scope [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-05-28 13:11:14 +02:00
parent cf5debba06
commit da14a74df9
1 changed files with 3 additions and 1 deletions

View File

@ -700,8 +700,10 @@ static void do_reset_environ(struct passwd *pw)
#else
environ = NULL;
#endif
if (term)
if (term) {
xsetenv("TERM", term, 1);
free(term);
}
if (pw->pw_shell && *pw->pw_shell)
xsetenv("SHELL", pw->pw_shell, 1);