diff options
Diffstat (limited to 'test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp')
-rw-r--r-- | test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp b/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp index fca02aa278fd..6fab8bb668e8 100644 --- a/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp +++ b/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp @@ -97,9 +97,11 @@ void testShouldReportDoubleFreeNotMismatched() { free(p); delete globalPtr; // expected-warning {{Attempt to free released memory}} } - +int *allocIntArray(unsigned c) { + return new int[c]; +} void testMismatchedChangePointeeThroughAssignment() { - int *arr = new int[4]; + int *arr = allocIntArray(4); globalPtr = arr; delete arr; // expected-warning{{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}} -}
\ No newline at end of file +} |