Call atexit handlers properly, avoiding a NPE and seg fault every time a

program exits.
This commit is contained in:
David Given 2018-09-09 18:51:00 +02:00
parent 2eaca39322
commit 79fd34dac6

View file

@ -15,8 +15,8 @@ int __funccnt = 0;
void exit(int status) void exit(int status)
{ {
/* "Called in reversed order of their registration" */ /* "Called in reversed order of their registration" */
while (__funccnt >= 0) while (__funccnt)
(*__functab[__funccnt])(); (*__functab[--__funccnt])();
_exit(status); _exit(status);
} }