]> git.saurik.com Git - apple/libc.git/blame - gen/FreeBSD/assert.c.patch
Libc-594.9.4.tar.gz
[apple/libc.git] / gen / FreeBSD / assert.c.patch
CommitLineData
34e8f829
A
1--- assert.c.orig 2008-09-06 16:27:37.000000000 -0700
2+++ assert.c 2008-09-07 01:35:02.000000000 -0700
3@@ -41,20 +41,39 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/ass
4 #include <stdio.h>
3d9156a7
A
5 #include <stdlib.h>
6
34e8f829
A
7+extern const char *__crashreporter_info__;
8+static const char badasprintf[] =
9+ "Assertion failed and asprintf also failed to create full error string";
10+
3d9156a7
A
11 void
12-__assert(func, file, line, failedexpr)
13+__assert_rtn(func, file, line, failedexpr)
14 const char *func, *file;
15 int line;
16 const char *failedexpr;
34e8f829
A
17 {
18- if (func == NULL)
19+ char *str = NULL;
20+
21+ if (func == NULL) {
22 (void)fprintf(stderr,
23 "Assertion failed: (%s), file %s, line %d.\n", failedexpr,
24 file, line);
25- else
26+ if (!__crashreporter_info__) {
27+ asprintf(&str,
28+ "Assertion failed: (%s), file %s, line %d.\n",
29+ failedexpr, file, line);
30+ __crashreporter_info__ = str ? str : badasprintf;
31+ }
32+ } else {
33 (void)fprintf(stderr,
34 "Assertion failed: (%s), function %s, file %s, line %d.\n",
35 failedexpr, func, file, line);
36+ if (!__crashreporter_info__) {
37+ asprintf(&str,
38+ "Assertion failed: (%s), function %s, file %s, line %d.\n",
39+ failedexpr, func, file, line);
40+ __crashreporter_info__ = str ? str : badasprintf;
41+ }
42+ }
43 abort();
44 /* NOTREACHED */
45 }