From: Manuel Novoa III Date: Sat, 17 Jan 2004 14:39:40 +0000 (-0000) Subject: Prevent runaway asserts, which can happen if there's a problem with X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=2bfa4ae4b8cb669fd4072c587bb52ca91af20a26;p=uclinux-h8%2Fuclibc-ng.git Prevent runaway asserts, which can happen if there's a problem with stdio or locales. --- 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(); }