summary refs log tree commit diff
path: root/sysdeps/mach/hurd
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-06-25 21:48:49 +0000
committerMiles Bader <miles@gnu.org>1996-06-25 21:48:49 +0000
commit315289fbb8910f6826c11a2b352d61c32b5eeb6d (patch)
tree765470a9581b8b86fcc0a8380db7c66cb7f91161 /sysdeps/mach/hurd
parent622586fbe088fbd0cca0533a046e65114c584526 (diff)
downloadglibc-315289fbb8910f6826c11a2b352d61c32b5eeb6d.tar.gz
glibc-315289fbb8910f6826c11a2b352d61c32b5eeb6d.tar.xz
glibc-315289fbb8910f6826c11a2b352d61c32b5eeb6d.zip
(_hurd_canonicalize_directory_name_internal): Initialize PARENT to THISDIR, and don't ever deallocate PARENT unless it != THISDIR.
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r--sysdeps/mach/hurd/getcwd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c
index 463b28ce29..a167730a0a 100644
--- a/sysdeps/mach/hurd/getcwd.c
+++ b/sysdeps/mach/hurd/getcwd.c
@@ -51,7 +51,9 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir,
 
   inline void cleanup (void)
     {
-      __mach_port_deallocate (__mach_task_self (), parent);
+      if (parent != thisdir)
+	__mach_port_deallocate (__mach_task_self (), parent);
+
       __mach_port_deallocate (__mach_task_self (), thisid);
       __mach_port_deallocate (__mach_task_self (), thisdevid);
       __mach_port_deallocate (__mach_task_self (), rootid);
@@ -101,6 +103,7 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir,
       return __hurd_fail (err), NULL;
     }
 
+  parent = thisdir;
   while (thisid != rootid)
     {
       /* PARENT is a port to the directory we are currently on;
@@ -121,7 +124,8 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir,
       newp = __file_name_lookup_under (parent, "..", O_READ, 0);
       if (newp == MACH_PORT_NULL)
 	goto lose;
-      __mach_port_deallocate (__mach_task_self (), parent);
+      if (parent != thisdir)
+	__mach_port_deallocate (__mach_task_self (), parent);
       parent = newp;
 
       /* Get this directory's identity and figure out if it's a mount point. */