Home | History | Annotate | Download | only in Analysis

Lines Matching full:malloc

1 // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s
2 // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
4 #include "Inputs/system-header-simulator-for-malloc.h"
7 // Check that unix.Malloc catches all types of bugs.
10 int *p = (int *)malloc(sizeof(int));
16 int *p = (int *)malloc(sizeof(int));
20 int *p = (int *)malloc(sizeof(int));
27 free(&i); // expected-warning{{Argument to free() is the address of the local variable 'i', which is not memory allocated by malloc()}}
31 int *p = (int *)malloc(sizeof(int));
32 free(++p); // expected-warning{{Argument to free() is offset by 4 bytes from the start of memory allocated by malloc()}}
39 int *x = (int *)malloc(sizeof(int));
40 delete x; // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
83 int *p = (int*)malloc(sizeof(int)*4);
89 int *p = (int*)malloc(sizeof(int)*4);
91 delete p; // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
95 int *p = (int*)malloc(sizeof(int)*4);