blob: 0ef064056b632761355da28ee5b06fff1732c1a2 [file] [log] [blame]
Kostya Serebryanya89a35a2013-03-26 08:01:37 +00001// RUN: %clangxx_asan -m64 -O0 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
2
3#include <stdlib.h>
4#include <string.h>
5int 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}