1 // RUN: %clang -O2 %s -o %t && %run %t 2 3 // Must not be implemented, no other reason to install interceptors. 4 // XFAIL: ubsan 5 6 #include <assert.h> 7 #include <malloc.h> 8 #include <sanitizer/allocator_interface.h> 9 #include <stdlib.h> 10 11 void *p; 12 main()13int main() { 14 assert(__sanitizer_get_allocated_size(NULL) == 0); 15 assert(malloc_usable_size(NULL) == 0); 16 17 int size = 1; 18 p = malloc(size); 19 assert(__sanitizer_get_allocated_size(p) == size); 20 assert(__sanitizer_get_allocated_size_fast(p) == size); 21 assert(malloc_usable_size(p) == size); 22 free(p); 23 24 size = 1234567; 25 p = malloc(size); 26 assert(__sanitizer_get_allocated_size(p) == size); 27 assert(__sanitizer_get_allocated_size_fast(p) == size); 28 assert(malloc_usable_size(p) == size); 29 free(p); 30 return 0; 31 } 32