summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-09-26 13:49:08 +0000
committerEric Andersen <andersen@codepoet.org>2002-09-26 13:49:08 +0000
commit0bb787fc273d2e2ce2b91196aee25f79f5d36194 (patch)
tree6607380109397be6b9157249efd438430a7674e3 /libc
parent3e2f4de2b24ce2e3bc1733f55292cf496eb4bd83 (diff)
A bug fix from Alexey V. Neyman:
In case of vfork(), the parent was left with __exit_count of -1 and thus tried to find non-NULL value of __exit_function_table[-1].atexit, __exit_function_table[-2].atexit and call this function; of course, it leads to coredump.
Diffstat (limited to 'libc')
-rw-r--r--libc/stdlib/atexit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index e4b6620e2..44abc343b 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -147,8 +147,8 @@ void __exit_handler(int status)
struct exit_function *efp;
/* In reverse order */
- for ( ; __exit_count-- ; ) {
- efp = &__exit_function_table[__exit_count];
+ while ( __exit_count ) {
+ efp = &__exit_function_table[--__exit_count];
switch (efp->type) {
case ef_on_exit:
if (efp->funcs.on_exit.func) {