Fix memory leak.
* libmisc/setupenv.c: Free pw_dir and pw_shell before reallocating them.
This commit is contained in:
@@ -228,6 +228,7 @@ void setup_env (struct passwd *info)
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
(void) puts (_("No directory, logging in with HOME=/"));
|
||||
free (info->pw_dir);
|
||||
info->pw_dir = xstrdup (temp_pw_dir);
|
||||
}
|
||||
|
||||
@@ -244,6 +245,7 @@ void setup_env (struct passwd *info)
|
||||
if ((NULL == info->pw_shell) || ('\0' == *info->pw_shell)) {
|
||||
static char temp_pw_shell[] = SHELL;
|
||||
|
||||
free (info->pw_shell);
|
||||
info->pw_shell = xstrdup (temp_pw_shell);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user