From 79fd34dac600e40000a22b9ee1b2ff4ceaea6d2c Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 9 Sep 2018 18:51:00 +0200 Subject: [PATCH] Call atexit handlers properly, avoiding a NPE and seg fault every time a program exits. --- lang/cem/libcc.ansi/sys/exit/exit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/cem/libcc.ansi/sys/exit/exit.c b/lang/cem/libcc.ansi/sys/exit/exit.c index 7f861321f..d16db6c3b 100644 --- a/lang/cem/libcc.ansi/sys/exit/exit.c +++ b/lang/cem/libcc.ansi/sys/exit/exit.c @@ -15,8 +15,8 @@ int __funccnt = 0; void exit(int status) { /* "Called in reversed order of their registration" */ - while (__funccnt >= 0) - (*__functab[__funccnt])(); + while (__funccnt) + (*__functab[--__funccnt])(); _exit(status); } -- 2.34.1