aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-11-13 00:21:47 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-11-13 01:23:51 +0100
commit946dcc6fde331a785d40d1341cc99a10ca304fd6 (patch)
treedc3a24d66a48291fb9259e0c9a20b84f983c83a4
parent7beee7b39adeda657f45989b0635033dae25a1fd (diff)
downloadglibc-946dcc6fde331a785d40d1341cc99a10ca304fd6.zip
glibc-946dcc6fde331a785d40d1341cc99a10ca304fd6.tar.gz
glibc-946dcc6fde331a785d40d1341cc99a10ca304fd6.tar.bz2
hurd: Make _hurd_libc_proc_init idempotent
For the cases where _init is getting called several times during startup. Better clean pointers anyway.
-rw-r--r--hurd/hurdinit.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c
index e4ec005..06a2d3b 100644
--- a/hurd/hurdinit.c
+++ b/hurd/hurdinit.c
@@ -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)