diff options
author | 2015-10-20 11:15:07 +0000 | |
---|---|---|
committer | 2015-10-20 11:15:07 +0000 | |
commit | 31b08222e46a5c824d06574863b8f73c72aea677 (patch) | |
tree | fd9045bda73d0b0ed8603843958519b50e7e16cc | |
parent | update regress for pledge after whitelisted-path view inclusion (diff) | |
download | wireguard-openbsd-31b08222e46a5c824d06574863b8f73c72aea677.tar.xz wireguard-openbsd-31b08222e46a5c824d06574863b8f73c72aea677.zip |
On xmalloc failure, stop trying to determine the total amount of allocated
memory up to this point by using sbrk(2). This is of course wildly incorrect
for any mmap-based malloc(3).
This also makes it possible to bring pledge(2) to gnu/.
comments kettenis@, ok miod@
-rw-r--r-- | gnu/lib/libiberty/src/xmalloc.c | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/gnu/lib/libiberty/src/xmalloc.c b/gnu/lib/libiberty/src/xmalloc.c index 3e97aab563f..5c95b8b0dd9 100644 --- a/gnu/lib/libiberty/src/xmalloc.c +++ b/gnu/lib/libiberty/src/xmalloc.c @@ -96,44 +96,19 @@ void *sbrk (ptrdiff_t); /* The program name if set. */ static const char *name = ""; -#ifdef HAVE_SBRK -/* The initial sbrk, set when the program name is set. Not used for win32 - ports other than cygwin32. */ -static char *first_break = NULL; -#endif /* HAVE_SBRK */ - void xmalloc_set_program_name (const char *s) { name = s; -#ifdef HAVE_SBRK - /* Win32 ports other than cygwin32 don't have brk() */ - if (first_break == NULL) - first_break = (char *) sbrk (0); -#endif /* HAVE_SBRK */ } void xmalloc_failed (size_t size) { -#ifdef HAVE_SBRK - extern char **environ; - size_t allocated; - - if (first_break != NULL) - allocated = (char *) sbrk (0) - first_break; - else - allocated = (char *) sbrk (0) - (char *) &environ; - fprintf (stderr, - "\n%s%sout of memory allocating %lu bytes after a total of %lu bytes\n", - name, *name ? ": " : "", - (unsigned long) size, (unsigned long) allocated); -#else /* HAVE_SBRK */ fprintf (stderr, "\n%s%sout of memory allocating %lu bytes\n", name, *name ? ": " : "", (unsigned long) size); -#endif /* HAVE_SBRK */ xexit (1); } |