diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2004-01-17 14:39:40 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2004-01-17 14:39:40 +0000 |
commit | 2bfa4ae4b8cb669fd4072c587bb52ca91af20a26 (patch) | |
tree | deaae35a5c5a32497a5d5e4abd3aa26d5f629154 /libc/misc/assert/__assert.c | |
parent | d8c8b456f45c773d0adac99f2997cbb0cab4c911 (diff) |
Prevent runaway asserts, which can happen if there's a problem with
stdio or locales.
Diffstat (limited to 'libc/misc/assert/__assert.c')
-rw-r--r-- | libc/misc/assert/__assert.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libc/misc/assert/__assert.c b/libc/misc/assert/__assert.c index 26bcc6516..74b5ee86f 100644 --- a/libc/misc/assert/__assert.c +++ b/libc/misc/assert/__assert.c @@ -46,21 +46,27 @@ extern const char *__progname; #if 1 +static int in_assert; /* bss inits to 0. */ + void __assert(const char *assertion, const char * filename, int linenumber, register const char * function) { - fprintf(stderr, + if (!in_assert) { + in_assert = 1; + + fprintf(stderr, #ifdef ASSERT_SHOW_PROGNAME - "%s: %s: %d: %s: Assertion `%s' failed.\n", __progname, + "%s: %s: %d: %s: Assertion `%s' failed.\n", __progname, #else - "%s: %d: %s: Assertion `%s' failed.\n", + "%s: %d: %s: Assertion `%s' failed.\n", #endif - filename, - linenumber, - /* Function name isn't available with some compilers. */ - ((function == NULL) ? "?function?" : function), - assertion - ); + filename, + linenumber, + /* Function name isn't available with some compilers. */ + ((function == NULL) ? "?function?" : function), + assertion + ); + } abort(); } |