summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-09-12 13:47:09 -0400
committerDavid Goulet <dgoulet@torproject.org>2019-09-12 13:47:09 -0400
commitc39c9ce26ba2990177e45a4c7bffaed51d88d280 (patch)
tree12f2d1bb8f4ae6f976a32e60d315afea3f0f7daf /src
parent028733e8b6f36bae420b1e41897401fa3b14ccf8 (diff)
parent52342327c7e566a25bf69dc6df651de45959e6d6 (diff)
downloadtor-c39c9ce26ba2990177e45a4c7bffaed51d88d280.tar.gz
tor-c39c9ce26ba2990177e45a4c7bffaed51d88d280.zip
Merge branch 'tor-github/pr/1285'
Diffstat (limited to 'src')
-rw-r--r--src/lib/malloc/map_anon.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/malloc/map_anon.c b/src/lib/malloc/map_anon.c
index 0f6a4150c7..79bbb99f72 100644
--- a/src/lib/malloc/map_anon.c
+++ b/src/lib/malloc/map_anon.c
@@ -27,6 +27,9 @@
#include <windows.h>
#endif
+#include <string.h>
+#include <errno.h>
+
/**
* Macro to get the high bytes of a size_t, if there are high bytes.
* Windows needs this; other operating systems define a size_t that does
@@ -108,7 +111,17 @@ static int
nodump_mem(void *mem, size_t sz)
{
#if defined(MADV_DONTDUMP)
- return madvise(mem, sz, MADV_DONTDUMP);
+ int rv = madvise(mem, sz, MADV_DONTDUMP);
+ if (rv == 0) {
+ return 0;
+ } else if (errno == ENOSYS || errno == EINVAL) {
+ return 0; // syscall not supported, or flag not supported.
+ } else {
+ tor_log_err_sigsafe("Unexpected error from madvise: ",
+ strerror(errno),
+ NULL);
+ return -1;
+ }
#else
(void) mem;
(void) sz;