| Kostya Serebryany | a89a35a | 2013-03-26 08:01:37 +0000 | [diff] [blame^] | 1 | // RUN: %clangxx_asan -m64 -O0 %s -o %t && %t 2>&1 | %symbolize | 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 | } |