commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 16/98: libshouldbeinlibc: fix reference counting in port_name_xla


From: Samuel Thibault
Subject: [hurd] 16/98: libshouldbeinlibc: fix reference counting in port_name_xlator_create
Date: Tue, 14 Jan 2014 01:59:58 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit 9b02c4454abee568af9ff1d6c9044e9cd757b5aa
Author: Justus Winter <address@hidden>
Date:   Thu Nov 7 17:01:02 2013 +0100

    libshouldbeinlibc: fix reference counting in port_name_xlator_create
    
    Both task ports are deallocated in the destructor, so they must be
    referenced in the constructor.
    
    * libshouldbeinlibc/portxlate.c (port_name_xlator_create): Fix
      reference counting.
---
 libshouldbeinlibc/portxlate.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libshouldbeinlibc/portxlate.c b/libshouldbeinlibc/portxlate.c
index 599fb58..8888e2c 100644
--- a/libshouldbeinlibc/portxlate.c
+++ b/libshouldbeinlibc/portxlate.c
@@ -35,7 +35,9 @@ port_name_xlator_create (mach_port_t from_task, mach_port_t 
to_task,
   if (! x)
     return ENOMEM;
 
+  mach_port_mod_refs (mach_task_self (), from_task, MACH_PORT_RIGHT_SEND, +1);
   x->from_task = from_task;
+  mach_port_mod_refs (mach_task_self (), to_task, MACH_PORT_RIGHT_SEND, +1);
   x->to_task = to_task;
   x->to_names = 0;
   x->to_types = 0;
@@ -64,6 +66,10 @@ port_name_xlator_create (mach_port_t from_task, mach_port_t 
to_task,
                  x->to_names_len * sizeof (mach_port_t));
          munmap ((caddr_t) x->to_types,
                  x->to_types_len * sizeof (mach_port_type_t));
+
+         mach_port_deallocate (mach_task_self (), x->to_task);
+         mach_port_deallocate (mach_task_self (), x->from_task);
+
          err = ENOMEM;
        }
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]