C++: Expand heuristic to catch more sources.

This commit is contained in:
Mathias Vorreiter Pedersen
2023-05-10 08:23:07 +01:00
parent 9da7c9f696
commit 363514e4ca
2 changed files with 2 additions and 2 deletions

View File

@@ -437,7 +437,7 @@ private module HeuristicAllocation {
int sizeArg;
HeuristicAllocationFunctionByName() {
Function.super.getName().matches("%alloc%") and
Function.super.getName().matches(["%alloc%", "%Alloc%"]) and
Function.super.getUnspecifiedType() instanceof PointerType and
sizeArg = unique( | | getAnUnsignedParameter(this))
}

View File

@@ -246,6 +246,6 @@ void test_flow_through_setter(unsigned size) {
void* my_alloc(unsigned size);
void foo(unsigned size) {
int* p = (int*)my_alloc(size); // BAD [NOT DETECTED]
int* p = (int*)my_alloc(size); // BAD
memset(p, 0, size + 1);
}