Module Name:    src
Committed By:   joerg
Date:           Mon Nov  6 14:26:03 UTC 2017

Modified Files:
        src/lib/libc/stdlib: atexit.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/stdlib/atexit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/atexit.c
diff -u src/lib/libc/stdlib/atexit.c:1.31 src/lib/libc/stdlib/atexit.c:1.32
--- src/lib/libc/stdlib/atexit.c:1.31	Thu Nov  2 19:39:33 2017
+++ src/lib/libc/stdlib/atexit.c	Mon Nov  6 14:26:03 2017
@@ -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 @@ __aeabi_atexit(void *arg, void (*func)(v
 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 @@ __cxa_atexit(void (*func)(void *), void 
 	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 @@ int
 atexit(void (*func)(void))
 {
 
-	return (__cxa_atexit((void (*)(void *))func, NULL, NULL));
+	return (__cxa_atexit_internal((void (*)(void *))func, NULL, NULL));
 }

Reply via email to