From 9150f397ba4c5478275d72665ea3e53a84c7076a Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Fri, 6 Sep 2013 09:25:11 +0000 Subject: [sanitizer] make the allocator crash instead of returning 0 on huge size (controlled by the allocator_may_return_null flag) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190127 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/sanitizer_common/sanitizer_allocator.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/sanitizer_common/sanitizer_allocator.cc') diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc index 2975073cf..daaf7e1ce 100644 --- a/lib/sanitizer_common/sanitizer_allocator.cc +++ b/lib/sanitizer_common/sanitizer_allocator.cc @@ -14,6 +14,7 @@ #include "sanitizer_allocator.h" #include "sanitizer_allocator_internal.h" #include "sanitizer_common.h" +#include "sanitizer_flags.h" namespace __sanitizer { @@ -139,4 +140,14 @@ bool CallocShouldReturnNullDueToOverflow(uptr size, uptr n) { return (max / size) < n; } +void *AllocatorReturnNull() { + if (common_flags()->allocator_may_return_null) + return 0; + Report("%s's allocator is terminating the process instead of returning 0\n", + SanitizerToolName); + Report("If you don't like this behavior set allocator_may_return_null=1\n"); + CHECK(0); + return 0; +} + } // namespace __sanitizer -- cgit v1.2.3