diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-02 12:53:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-02 12:55:20 -0400 |
commit | 57c48bf7342d8df9bd3fbd8d52d6bf570b2ecac2 (patch) | |
tree | 614437662e478ceeb9006f69723b94b85c860b0d /src/common | |
parent | 00ffccd9a6d9b7f484c2e421be33aea3975a2879 (diff) | |
download | tor-57c48bf7342d8df9bd3fbd8d52d6bf570b2ecac2.tar.gz tor-57c48bf7342d8df9bd3fbd8d52d6bf570b2ecac2.zip |
Apply the MALLOC_ZERO_WORKS fixup to tor_realloc as well.
Also, make MALLOC_ZERO_WORKS never get applied when clang analyzer is
running. This should make the clangalyzer a little happier.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 16ff8e3a80..3f298cd9c4 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -96,6 +96,10 @@ #include <sys/wait.h> #endif +#ifdef __clang_analyzer__ +#undef MALLOC_ZERO_WORKS +#endif + /* ===== * Assertion helper. * ===== */ @@ -231,6 +235,13 @@ tor_realloc_(void *ptr, size_t size DMALLOC_PARAMS) tor_assert(size < SIZE_T_CEILING); +#ifndef MALLOC_ZERO_WORKS + /* Some libc mallocs don't work when size==0. Override them. */ + if (size==0) { + size=1; + } +#endif + #ifdef USE_DMALLOC result = dmalloc_realloc(file, line, ptr, size, DMALLOC_FUNC_REALLOC, 0); #else |