diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-01-17 13:25:17 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-01-17 13:25:17 +0000 |
commit | 220ba2f6f98d44e1e8a88b4dee8ed456cf54ff33 (patch) | |
tree | bee9f38045ca323bb4e3277d2ffc79b8b495084f /lib/asan/tests/asan_noinst_test.cc | |
parent | 7be1cc87ba99036519437518ec8eb9231916241b (diff) |
[ASan] fix __asan_get_ownership(p) and __asan_get_allocated_size(p) for the p = malloc(0)
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172717 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/tests/asan_noinst_test.cc')
-rw-r--r-- | lib/asan/tests/asan_noinst_test.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/asan/tests/asan_noinst_test.cc b/lib/asan/tests/asan_noinst_test.cc index fc4a3d1f5..8a7f77455 100644 --- a/lib/asan/tests/asan_noinst_test.cc +++ b/lib/asan/tests/asan_noinst_test.cc @@ -382,8 +382,16 @@ TEST(AddressSanitizerInterface, GetAllocatedSizeAndOwnershipTest) { free(array); EXPECT_FALSE(__asan_get_ownership(array)); EXPECT_DEATH(__asan_get_allocated_size(array), kGetAllocatedSizeErrorMsg); - delete int_ptr; + + void *zero_alloc = Ident(malloc(0)); + if (zero_alloc != 0) { + // If malloc(0) is not null, this pointer is owned and should have valid + // allocated size. + EXPECT_TRUE(__asan_get_ownership(zero_alloc)); + EXPECT_EQ(0U, __asan_get_allocated_size(zero_alloc)); + } + free(zero_alloc); } TEST(AddressSanitizerInterface, GetCurrentAllocatedBytesTest) { |