Commit 57c48bf7 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

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.
parent 00ffccd9
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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