Files
clang-p2996/compiler-rt/test/asan/TestCases/inline.cpp
Kamil Rytarowski 5fe1e55d35 Avoid memory leak in ASan test
Summary:
Add missing free(3) for the malloc(3) call.

Detected on NetBSD with LSan.

Reviewers: joerg, mgorny, vitalybuka, dvyukov

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D67330

llvm-svn: 372460
2019-09-21 07:43:55 +00:00

21 lines
418 B
C++

// RUN: %clangxx_asan -O3 %s -o %t && %run %t
// Test that no_sanitize_address attribute applies even when the function would
// be normally inlined.
#include <stdlib.h>
__attribute__((no_sanitize_address))
int f(int *p) {
return *p; // BOOOM?? Nope!
}
int main(int argc, char **argv) {
int * volatile x = (int*)malloc(2*sizeof(int) + 2);
int res = f(x + 2);
free(x);
if (res)
exit(0);
return 0;
}