Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib Assert that __cxa_atexit is not used with NU...



details:   https://anonhg.NetBSD.org/src/rev/04011a657319
branches:  trunk
changeset: 827637:04011a657319
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Nov 06 14:26:03 2017 +0000

description:
Assert that __cxa_atexit is not used with NULL as DSO. Don't use
__cxa_atexit directly from atexit, they have different behavior.

diffstat:

 lib/libc/stdlib/atexit.c |  19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diffs (55 lines):

diff -r cebd6d2c8fbf -r 04011a657319 lib/libc/stdlib/atexit.c
--- a/lib/libc/stdlib/atexit.c  Mon Nov 06 10:51:40 2017 +0000
+++ b/lib/libc/stdlib/atexit.c  Mon Nov 06 14:26:03 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atexit.c,v 1.31 2017/11/02 19:39:33 kamil Exp $        */
+/*     $NetBSD: atexit.c,v 1.32 2017/11/06 14:26:03 joerg Exp $        */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: atexit.c,v 1.31 2017/11/02 19:39:33 kamil Exp $");
+__RCSID("$NetBSD: atexit.c,v 1.32 2017/11/06 14:26:03 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "reentrant.h"
@@ -142,12 +142,12 @@
 int
 __aeabi_atexit(void *arg, void (*func)(void *), void *dso)
 {
-       return __cxa_atexit(func, arg, dso);
+       return (__cxa_atexit(func, arg, dso));
 }
 #endif
 
-int
-__cxa_atexit(void (*func)(void *), void *arg, void *dso)
+static int
+__cxa_atexit_internal(void (*func)(void *), void *arg, void *dso)
 {
        struct atexit_handler *ah;
 
@@ -172,6 +172,13 @@
        return (0);
 }
 
+int
+__cxa_atexit(void (*func)(void *), void *arg, void *dso)
+{
+       _DIAGASSERT(dso != NULL);
+       return (__cxa_atexit_internal(func, arg, dso));
+}
+
 /*
  * Run the list of atexit handlers.  If dso is NULL, run all of them,
  * otherwise run only those matching the specified dso.
@@ -255,5 +262,5 @@
 atexit(void (*func)(void))
 {
 
-       return (__cxa_atexit((void (*)(void *))func, NULL, NULL));
+       return (__cxa_atexit_internal((void (*)(void *))func, NULL, NULL));
 }



Home | Main Index | Thread Index | Old Index