Bradley Morgan, le dim. 21 juin 2026 18:18:55 +0000, a ecrit: > ids falls back to authenticating with its own auth port when proc_pid2task > fails. In that path, task was never initialized but was still passed to > mach_port_deallocate after msg_get_init_port succeeded. > > Initialize the task port and only deallocate it when it is valid.
Mmm, better simply move the deallocation call into the !err part of the if? Thanks for spotting it, Samuel > Signed-off-by: Bradley Morgan <[email protected]> > --- > utils/ids.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/utils/ids.c b/utils/ids.c > index 94fe6793..58ba47f5 100644 > --- a/utils/ids.c > +++ b/utils/ids.c > @@ -52,7 +52,7 @@ int > main(int argc, char *argv[]) > { > error_t err; > - task_t task; > + task_t task = MACH_PORT_NULL; > mach_port_t msgport; > int pid = -1; > auth_t auth = getauth (); > @@ -147,7 +147,8 @@ main(int argc, char *argv[]) > error (6, err, "%d: Cannot get process authentication", pid); > > mach_port_deallocate (mach_task_self (), msgport); > - mach_port_deallocate (mach_task_self (), task); > + if (MACH_PORT_VALID (task)) > + mach_port_deallocate (mach_task_self (), task); > > /* Get the ids that AUTH represents. */ > err = ugids_merge_auth (&ugids, auth); > -- > 2.53.0 > >
