C++: Add test cases for HeuristicAllocationExpr in queries.

This commit is contained in:
Geoffrey White
2023-01-05 10:38:34 +00:00
parent 10ca2dac19
commit a9aa67177b
6 changed files with 78 additions and 2 deletions

View File

@@ -58,3 +58,14 @@ void test_union() {
MyUnion *a = malloc(sizeof(MyUnion)); // GOOD
MyUnion *b = malloc(sizeof(MyStruct)); // BAD (too small)
}
// --- custom allocators ---
void *MyMalloc1(size_t size) { return malloc(size); }
void *MyMalloc2(size_t size);
void customAllocatorTests()
{
float *fptr1 = MyMalloc1(3); // BAD (too small) [NOT DETECTED]
float *fptr2 = MyMalloc2(3); // BAD (too small) [NOT DETECTED]
}