diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-11-02 08:29:10 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-11-02 08:29:10 +0000 |
commit | 5d8ce82d8c7dca45f33a21967e0b8c5406b5ca9f (patch) | |
tree | c796fc5c7cc2943262512adbf3d6a5e82efb8c90 /libc/stdlib | |
parent | a30a999bb02478243fe4c0b3d012596c5398dfdd (diff) |
If realloc failed, we'd lose the pointer to the exit function table.
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/atexit.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c index 8b04e8a04..ab124a09f 100644 --- a/libc/stdlib/atexit.c +++ b/libc/stdlib/atexit.c @@ -96,13 +96,14 @@ int atexit(aefuncp func) #ifdef __UCLIBC_DYNAMIC_ATEXIT__ /* If we are out of function table slots, make some more */ if (__exit_slots < __exit_count+1) { - __exit_function_table=realloc(__exit_function_table, - (__exit_slots+20)*sizeof(struct exit_function)); - if (__exit_function_table==NULL) { + efp=realloc(__exit_function_table, + (__exit_slots+20)*sizeof(struct exit_function)); + if (efp==NULL) { UNLOCK; __set_errno(ENOMEM); return -1; } + __exit_function_table = efp; __exit_slots+=20; } #else @@ -138,13 +139,14 @@ int on_exit(oefuncp func, void *arg) #ifdef __UCLIBC_DYNAMIC_ATEXIT__ /* If we are out of function table slots, make some more */ if (__exit_slots < __exit_count+1) { - __exit_function_table=realloc(__exit_function_table, - (__exit_slots+20)*sizeof(struct exit_function)); - if (__exit_function_table==NULL) { + efp=realloc(__exit_function_table, + (__exit_slots+20)*sizeof(struct exit_function)); + if (efp==NULL) { UNLOCK; __set_errno(ENOMEM); return -1; } + __exit_function_table=efp; __exit_slots+=20; } #else |