diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-01-04 01:13:09 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-01-04 01:13:09 +0100 |
commit | d60191077b494d6a60181dd4967fe9dafa7003cc (patch) | |
tree | 899255030d0a2431f1d214ad912b1b2e5da49a7d | |
parent | a179160d41424813a2cf07ab554180804ae14fdf (diff) | |
download | hurd-d60191077b494d6a60181dd4967fe9dafa7003cc.tar.gz hurd-d60191077b494d6a60181dd4967fe9dafa7003cc.tar.bz2 hurd-d60191077b494d6a60181dd4967fe9dafa7003cc.zip |
login: More port leaks fixes
ports[INIT_PORT_CRDIR] and [INIT_PORT_CWDIR] were obtained from getcrdir()
and getcwdir(), so a referenced needs to be released when replacing
them.
-rw-r--r-- | utils/login.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/utils/login.c b/utils/login.c index eb0ed845..553629c6 100644 --- a/utils/login.c +++ b/utils/login.c @@ -787,7 +787,10 @@ main(int argc, char *argv[]) envz_add (&args, &args_len, "HOME", "/"); } else - ports[INIT_PORT_CWDIR] = cwd; + { + mach_port_deallocate (ports[INIT_PORT_CWDIR]); + ports[INIT_PORT_CWDIR] = cwd; + } } arg = envz_get (args, args_len, "ROOT"); @@ -878,7 +881,11 @@ main(int argc, char *argv[]) /* Now that we don't need to use PORTS for lookups anymore, put the correct ROOT in. */ - ports[INIT_PORT_CRDIR] = root; + if (ports[INIT_PORT_CRDIR] != root) + { + mach_port_deallocate (mach_task_self (), ports[INIT_PORT_CRDIR]); + ports[INIT_PORT_CRDIR] = root; + } /* Get rid of any accumulated null entries in env. */ envz_strip (&env, &env_len); |