diff options
author | imp <imp@FreeBSD.org> | 2001-02-16 21:09:49 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2001-02-16 21:09:49 +0000 |
commit | 2d4d551f1e3e17187f3dcab9b05dc5dd63d244a6 (patch) | |
tree | d41601a707e1769e8d97c765a7465d721d540d48 /lib/libc | |
parent | 58771d947161b0a60d5919672c5bcf7a83f9774b (diff) | |
download | FreeBSD-src-2d4d551f1e3e17187f3dcab9b05dc5dd63d244a6.zip FreeBSD-src-2d4d551f1e3e17187f3dcab9b05dc5dd63d244a6.tar.gz |
Extra needs to be initialized for our usual pool of FILEs. This was
causing some versions of as to dump core. This survived make
buildworld/installworld and the building gettext port afterwards.
Submitted by: <nnd@mail.nsk.ru> "N.Dudorov"
Reviewed by: "Daniel M. Eischen" <eischen@vigrid.com>
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdio/findfp.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index e0f0e29..4911400 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -66,6 +66,7 @@ int __sdidinit; /* _ub _extra */ /* the usual - (stdin + stdout + stderr) */ static FILE usual[FOPEN_MAX - 3]; +static struct __sFILEX usual_extra[FOPEN_MAX - 3]; static struct glue uglue = { NULL, FOPEN_MAX - 3, usual }; static struct __sFILEX __sFX[3]; @@ -215,7 +216,17 @@ _cleanup() void __sinit() { - /* Make sure we clean up on exit. */ - __cleanup = _cleanup; /* conservative */ - __sdidinit = 1; + int i; + + THREAD_LOCK(); + if (__sdidinit == 0) { + /* Set _extra for the usual suspects. */ + for (i = 0; i < FOPEN_MAX - 3; i++) + usual[i]._extra = &usual_extra[i]; + + /* Make sure we clean up on exit. */ + __cleanup = _cleanup; /* conservative */ + __sdidinit = 1; + } + THREAD_UNLOCK(); } |