aboutsummaryrefslogtreecommitdiff
path: root/assert/assert.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-06 08:49:08 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-06 08:49:08 +0000
commit383bd1c5033b466ffcc1a0be766d8a8b003c73e9 (patch)
tree06aec2446da55eee38518fb8296728d0910f258d /assert/assert.c
parent1e06620a7b9c6c65284c52b4625eabd23b14c77c (diff)
downloadglibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.tar
glibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.tar.gz
glibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.tar.bz2
glibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.zip
Update.
2001-12-06 Ulrich Drepper <drepper@redhat.com> * libio/vasprintf.c (_IO_vasprintf): Free buffer on failure. * assert/assert.c: Check result of __asprintf call and don't use string if it failed. * assert/assert-perr.c: Likewise. * inet/rcmd.c: Likewise. * locale/programs/localedef.c (main): Check result of construct_output_path and exit if it failed. (construct_output_path): Check result of asprintf and mkdir calls and fail if they failed. * posix/getopt.c: Check result of __asprintf calls and fail if they failed. Patch by Dmitry V. Levin <ldv@alt-linux.org>.
Diffstat (limited to 'assert/assert.c')
-rw-r--r--assert/assert.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/assert/assert.c b/assert/assert.c
index df382456e3..6a9c4de55d 100644
--- a/assert/assert.c
+++ b/assert/assert.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sysdep.h>
+#include <unistd.h>
extern const char *__progname;
@@ -51,25 +52,30 @@ __assert_fail (const char *assertion, const char *file, unsigned int line,
FATAL_PREPARE;
#endif
- (void) __asprintf (&buf, _("%s%s%s:%u: %s%sAssertion `%s' failed.\n"),
- __progname, __progname[0] ? ": " : "",
- file, line,
- function ? function : "", function ? ": " : "",
- assertion);
-
- /* Print the message. */
+ if (__asprintf (&buf, _("%s%s%s:%u: %s%sAssertion `%s' failed.\n"),
+ __progname, __progname[0] ? ": " : "",
+ file, line,
+ function ? function : "", function ? ": " : "",
+ assertion) >= 0)
+ {
+ /* Print the message. */
#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", buf);
- else
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", buf);
+ else
#endif
- (void) fputs (buf, stderr);
+ (void) fputs (buf, stderr);
- (void) fflush (stderr);
+ (void) fflush (stderr);
- /* We have to free the buffer since the appplication might catch the
- SIGABRT. */
- free (buf);
+ /* We have to free the buffer since the appplication might catch the
+ SIGABRT. */
+ free (buf);
+ }
+ else
+ /* At least print a minimal message. */
+#define STR_N_LEN(str) str, sizeof (str) - 1
+ __libc_write (STDERR_FILENO, STR_N_LEN ("Unexpected error.\n"));
abort ();
}