Confirm that ASAN will catch use-after-free errors, even if the BufferAllocator caches returned memory.
| 82 | // Confirm that ASAN will catch use-after-free errors, even if the BufferAllocator caches |
| 83 | // returned memory. |
| 84 | TEST_F(BufferAllocatorTest, Poisoning) { |
| 85 | BufferAllocator allocator(dummy_pool_, test_env_->metrics(), TEST_BUFFER_LEN, |
| 86 | 2 * TEST_BUFFER_LEN, 2 * TEST_BUFFER_LEN); |
| 87 | BufferHandle buffer; |
| 88 | ASSERT_OK(allocator.Allocate(&dummy_client_, TEST_BUFFER_LEN, &buffer)); |
| 89 | uint8_t* data = buffer.data(); |
| 90 | allocator.Free(move(buffer)); |
| 91 | |
| 92 | // Should trigger a ASAN failure. |
| 93 | ASSERT_DEATH({data[10] = 0;}, "use-after-poison"); |
| 94 | } |
| 95 | |
| 96 | #endif |
| 97 |
nothing calls this directly
no test coverage detected