From 8e67b39eb4a3abb6f3e35de3ad6e5d06ed0e8498 Mon Sep 17 00:00:00 2001 From: Paul Pluzhnikov Date: Sat, 1 Sep 2018 10:50:41 -0700 Subject: stdlib: assert on NULL function pointer in atexit etc. [BZ #20544] --- stdlib/on_exit.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'stdlib/on_exit.c') diff --git a/stdlib/on_exit.c b/stdlib/on_exit.c index 5241e0d86f..1dff7ff631 100644 --- a/stdlib/on_exit.c +++ b/stdlib/on_exit.c @@ -15,6 +15,7 @@ License along with the GNU C Library; if not, see . */ +#include #include #include "exit.h" #include @@ -25,6 +26,10 @@ __on_exit (void (*func) (int status, void *arg), void *arg) { struct exit_function *new; + /* As a QoI issue we detect NULL early with an assertion instead + of a SIGSEGV at program exit when the handler is run (bug 20544). */ + assert (func != NULL); + __libc_lock_lock (__exit_funcs_lock); new = __new_exitfn (&__exit_funcs); -- cgit v1.2.3