2016-11-09 02:12:56 +08:00
|
|
|
// RUN: clang-tidy %s -checks='-*,clang-analyzer-*' -- | FileCheck %s
|
2014-02-12 17:52:07 +08:00
|
|
|
extern void *malloc(unsigned long);
|
|
|
|
extern void free(void *);
|
2013-11-14 23:49:44 +08:00
|
|
|
|
|
|
|
void f() {
|
|
|
|
int *p = new int(42);
|
|
|
|
delete p;
|
|
|
|
delete p;
|
2014-02-12 17:52:07 +08:00
|
|
|
// CHECK: warning: Attempt to free released memory [clang-analyzer-cplusplus.NewDelete]
|
|
|
|
}
|
|
|
|
|
|
|
|
void g() {
|
|
|
|
void *q = malloc(132);
|
|
|
|
free(q);
|
|
|
|
free(q);
|
|
|
|
// CHECK: warning: Attempt to free released memory [clang-analyzer-unix.Malloc]
|
2013-11-14 23:49:44 +08:00
|
|
|
}
|