From cd6270c19d6b961e77c41823e82e2e76ddc789c8 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 4 Dec 2016 21:05:51 +0100 Subject: Fix port leak --- hurd/hurdselect.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hurd/hurdselect.c b/hurd/hurdselect.c index e9e9b3e85b..dcda71b63f 100644 --- a/hurd/hurdselect.c +++ b/hurd/hurdselect.c @@ -288,7 +288,9 @@ _hurd_select (int nfds, portset = MACH_PORT_NULL; for (i = firstfd; i <= lastfd; ++i) - if (d[i].type & ~SELECT_ERROR) + if (d[i].type & SELECT_ERROR) + d[i].reply_port = MACH_PORT_NULL; + else { int type = d[i].type; d[i].reply_port = __mach_reply_port (); @@ -491,7 +493,7 @@ _hurd_select (int nfds, if (firstfd != -1) for (i = firstfd; i <= lastfd; ++i) - if (d[i].type & ~(SELECT_ERROR | SELECT_RETURNED)) + if (d[i].reply_port != MACH_PORT_NULL) __mach_port_destroy (__mach_task_self (), d[i].reply_port); if (firstfd == -1 || (firstfd != lastfd && portset != MACH_PORT_NULL)) /* Destroy PORTSET, but only if it's not actually the reply port for a -- cgit v1.2.3