From 26526e667ffb92825e864a0960700ddd63a24558 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 6 Aug 2010 12:07:03 -0400 Subject: [PATCH] delref sudo_user.pw, runas_pw and runas_gr immediately before we return. --- plugins/sudoers/sudoers.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 47b07d670..d51998688 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -585,10 +585,6 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], (void) sigaction(SIGQUIT, &saved_sa_quit, NULL); (void) sigaction(SIGTSTP, &saved_sa_tstp, NULL); - /* Close the password and group files and free up memory. */ - sudo_endpwent(); - sudo_endgrent(); - if (ISSET(sudo_mode, MODE_EDIT)) { char *editor = find_editor(NewArgc - 1, NewArgv + 1, &edit_argv); if (!editor) @@ -654,6 +650,14 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], restore_perms(); done: + /* Close the password and group files and free up memory. */ + sudo_endpwent(); + sudo_endgrent(); + pw_delref(sudo_user.pw); + pw_delref(runas_pw); + if (runas_gr != NULL) + gr_delref(runas_gr); + return rval; } -- 2.40.0