]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Make _hurd_libc_proc_init idempotent
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Fri, 13 Nov 2020 00:21:47 +0000 (00:21 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Fri, 13 Nov 2020 00:23:51 +0000 (01:23 +0100)
For the cases where _init is getting called several times during startup. Better
clean pointers anyway.

hurd/hurdinit.c

index e4ec005b48f35a64cb633756d0d3c6dc9bad43c4..06a2d3b7fddad207850b9d8d65c63cc3c0ee3296 100644 (file)
@@ -114,17 +114,25 @@ libc_hidden_def (_hurd_init)
 void
 _hurd_libc_proc_init (char **argv)
 {
-  /* Tell the proc server we exist, if it does.  */
-  if (_hurd_portarray[INIT_PORT_PROC] != MACH_PORT_NULL)
-    _hurd_new_proc_init (argv, _hurd_intarray, _hurd_intarraysize);
-
-  /* All done with init ints and ports.  */
-  __vm_deallocate (__mach_task_self (),
-                  (vm_address_t) _hurd_intarray,
-                  _hurd_intarraysize * sizeof (int));
-  __vm_deallocate (__mach_task_self (),
-                  (vm_address_t) _hurd_portarray,
-                  _hurd_portarraysize * sizeof (mach_port_t));
+  if (_hurd_portarray)
+    {
+      /* Tell the proc server we exist, if it does.  */
+      if (_hurd_portarray[INIT_PORT_PROC] != MACH_PORT_NULL)
+       _hurd_new_proc_init (argv, _hurd_intarray, _hurd_intarraysize);
+
+      /* All done with init ints and ports.  */
+      __vm_deallocate (__mach_task_self (),
+                      (vm_address_t) _hurd_intarray,
+                      _hurd_intarraysize * sizeof (int));
+      _hurd_intarray = NULL;
+      _hurd_intarraysize = 0;
+
+      __vm_deallocate (__mach_task_self (),
+                      (vm_address_t) _hurd_portarray,
+                      _hurd_portarraysize * sizeof (mach_port_t));
+      _hurd_portarray = NULL;
+      _hurd_portarraysize = 0;
+    }
 }
 libc_hidden_def (_hurd_libc_proc_init)
 \f