From c290af8a3203ce9897574b381c4d1fa2977c315d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 6 May 2011 01:05:22 +0200 Subject: Fix port leak * libtrivfs/file-reparent.c (trivfs_S_file_reparent): Deallocate `parent' port when the trivfs_S_io_duplicate() call succeeds. --- libtrivfs/file-reparent.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libtrivfs') diff --git a/libtrivfs/file-reparent.c b/libtrivfs/file-reparent.c index c07fbccb..0682a912 100644 --- a/libtrivfs/file-reparent.c +++ b/libtrivfs/file-reparent.c @@ -27,5 +27,8 @@ trivfs_S_file_reparent (struct trivfs_protid *cred, mach_port_t *new, mach_msg_type_name_t *new_type) { /* This is not a directory, so we just duplicate it */ - return trivfs_S_io_duplicate (cred, reply, reply_type, new, new_type); + error_t ret = trivfs_S_io_duplicate (cred, reply, reply_type, new, new_type); + if (!ret) + mach_port_deallocate (mach_task_self (), parent); + return ret; } -- cgit v1.2.3