diff options
author | Karel Zak | 2015-01-29 11:26:09 +0100 |
---|---|---|
committer | Karel Zak | 2015-01-29 11:26:09 +0100 |
commit | 101c5838aca7cc259f0d06626e993a21792c8232 (patch) | |
tree | 8b8e3a115ec7198317d127b24676fb0e320a60f9 | |
parent | login: fix mem leak in init_environ() [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-101c5838aca7cc259f0d06626e993a21792c8232.tar.gz kernel-qcow2-util-linux-101c5838aca7cc259f0d06626e993a21792c8232.tar.xz kernel-qcow2-util-linux-101c5838aca7cc259f0d06626e993a21792c8232.zip |
su: fix mem leak in modify_environ() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | login-utils/su-common.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/login-utils/su-common.c b/login-utils/su-common.c index 57038ce37..2d4707330 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -533,13 +533,15 @@ modify_environment (const struct passwd *pw, const char *shell) { /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. Unset all other environment variables. */ - char const *term = getenv ("TERM"); + char *term = getenv ("TERM"); if (term) term = xstrdup (term); environ = xmalloc ((6 + !!term) * sizeof (char *)); environ[0] = NULL; - if (term) + if (term) { xsetenv ("TERM", term, 1); + free(term); + } xsetenv ("HOME", pw->pw_dir, 1); if (shell) xsetenv ("SHELL", shell, 1); |