aboutsummaryrefslogtreecommitdiff
path: root/stdlib/on_exit.c
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2018-09-01 10:50:41 -0700
committerPaul Pluzhnikov <ppluzhnikov@google.com>2018-11-30 16:18:34 -0800
commit8e67b39eb4a3abb6f3e35de3ad6e5d06ed0e8498 (patch)
tree32cb45ac608306b882ba1dab40756ea9eafc12d8 /stdlib/on_exit.c
parent15b8d67e29142251a30576b5ab469051a8833e97 (diff)
downloadglibc-8e67b39eb4a3abb6f3e35de3ad6e5d06ed0e8498.zip
glibc-8e67b39eb4a3abb6f3e35de3ad6e5d06ed0e8498.tar.gz
glibc-8e67b39eb4a3abb6f3e35de3ad6e5d06ed0e8498.tar.bz2
stdlib: assert on NULL function pointer in atexit etc. [BZ #20544]
Diffstat (limited to 'stdlib/on_exit.c')
-rw-r--r--stdlib/on_exit.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/stdlib/on_exit.c b/stdlib/on_exit.c
index 5241e0d..1dff7ff 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
<http://www.gnu.org/licenses/>. */
+#include <assert.h>
#include <stdlib.h>
#include "exit.h"
#include <sysdep.h>
@@ -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);