1 // RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s 2 3 #include <stdlib.h> 4 #include <string.h> 5 int main(int argc, char **argv) { 6 char *x = (char*)malloc(10 * sizeof(char)); 7 memset(x, 0, 10); 8 int res = x[argc]; 9 free(x + 5); // BOOM 10 // CHECK: AddressSanitizer: attempting free on address{{.*}}in thread T0 11 // CHECK: invalid-free.cc:[[@LINE-2]] 12 // CHECK: is located 5 bytes inside of 10-byte region 13 // CHECK: allocated by thread T0 here: 14 // CHECK: invalid-free.cc:[[@LINE-8]] 15 return res; 16 } 17