// checkers bounded with cplusplus.NewDelete.
//----------------------------------------------------------------------------
-// malloc()/free() are subjects of unix.Malloc and unix.MallocWithAnnotations
+//----- malloc()/free() are subjects of unix.Malloc and unix.MallocWithAnnotations
void testMallocFreeNoWarn() {
int i;
free(&i); // no warn
free(p2); // no warn
int *p3 = (int *)malloc(sizeof(int)); // no warn
+
+ int *p4 = (int *)malloc(sizeof(int));
+ free(p4);
+ int j = *p4; // no warn
}
void testDeleteMalloced() {
void *p = operator new(0);
free(p);
} // expected-warning{{Memory is never released; potential leak}}
-// FIXME: Pointer should escape
void testFreeNewExpr() {
int *p = new int;
free(p);
} // expected-warning{{Memory is never released; potential leak}}
-// FIXME: Pointer should escape
void testObjcFreeNewed() {
int *p = new int;
NSData *nsdata = [NSData dataWithBytesNoCopy:p length:sizeof(int) freeWhenDone:1]; // expected-warning{{Memory is never released; potential leak}}
}
-// FIXME: Pointer should escape
void testFreeAfterDelete() {
int *p = new int;