(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)
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;
}