1 // RUN: %clang_scudo %s -lstdc++ -o %t 2 // RUN: %run %t 2>&1 3 4 // Tests that the sanitizer interface functions behave appropriately. 5 6 #include <stdlib.h> 7 8 #include <vector> 9 10 #include <sanitizer/allocator_interface.h> 11 12 int main(int argc, char **argv) 13 { 14 void *p; 15 std::vector<ssize_t> sizes{1, 8, 16, 32, 1024, 32768, 16 1 << 16, 1 << 17, 1 << 20, 1 << 24}; 17 for (size_t size : sizes) { 18 p = malloc(size); 19 if (!p) 20 return 1; 21 if (!__sanitizer_get_ownership(p)) 22 return 1; 23 if (__sanitizer_get_allocated_size(p) < size) 24 return 1; 25 free(p); 26 } 27 return 0; 28 } 29