19 lines · cpp
1// REQUIRES: static-analyzer2// RUN: clang-tidy %s -checks='-*,clang-analyzer-*' -- | FileCheck %s3extern void *malloc(unsigned long);4extern void free(void *);5 6void f() {7 int *p = new int(42);8 delete p;9 delete p;10 // CHECK: warning: Attempt to release already released memory [clang-analyzer-cplusplus.NewDelete]11}12 13void g() {14 void *q = malloc(132);15 free(q);16 free(q);17 // CHECK: warning: Attempt to release already released memory [clang-analyzer-unix.Malloc]18}19