summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_allocator.cc
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-09-06 09:25:11 +0000
committerKostya Serebryany <kcc@google.com>2013-09-06 09:25:11 +0000
commit9150f397ba4c5478275d72665ea3e53a84c7076a (patch)
tree30352c659126691fa2426a4158f06cc20a878f1f /lib/sanitizer_common/sanitizer_allocator.cc
parenta27512c4e115df4f260501a94b8d343f9ed955af (diff)
[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
Diffstat (limited to 'lib/sanitizer_common/sanitizer_allocator.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_allocator.cc11
1 files changed, 11 insertions, 0 deletions
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