Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef131d3

Browse files
committed
C++: Fix StandardDeallocationFunction.
1 parent 281b56b commit ef131d3

1 file changed

Lines changed: 34 additions & 36 deletions

File tree

cpp/ql/src/semmle/code/cpp/models/implementations/Deallocation.qll

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,43 @@ private class StandardDeallocationFunction extends DeallocationFunction {
1313
int freedArg;
1414

1515
StandardDeallocationFunction() {
16-
exists(string name |
17-
hasGlobalName([
16+
hasGlobalName([
1817
// --- C library allocation
1918
"free", "realloc",
2019
// --- OpenSSL memory allocation
21-
"CRYPTO_free", "CRYPTO_secure_free"]
22-
) and
23-
freedArg = 0
24-
or
25-
hasGlobalOrStdName([
26-
// --- Windows Memory Management for Windows Drivers
27-
"ExFreePoolWithTag", "ExDeleteTimer", "IoFreeMdl", "IoFreeWorkItem",
28-
"IoFreeErrorLogEntry", "MmFreeContiguousMemory", "MmFreeContiguousMemorySpecifyCache",
29-
"MmFreeNonCachedMemory", "MmFreeMappingAddress", "MmFreePagesFromMdl",
30-
"MmUnmapReservedMapping", "MmUnmapLockedPages",
31-
// --- Windows Global / Local legacy allocation
32-
"LocalFree", "GlobalFree", "LocalReAlloc", "GlobalReAlloc",
33-
// --- Windows System Services allocation
34-
"VirtualFree",
35-
// --- Windows COM allocation
36-
"CoTaskMemFree", "CoTaskMemRealloc",
37-
// --- Windows Automation
38-
"SysFreeString",
39-
// --- Linux kernel memory allocator
40-
"kmem_free"
41-
]) and
42-
freedArg = 0
43-
or
44-
hasGlobalOrStdName([
45-
// --- Windows Memory Management for Windows Drivers
46-
"ExFreeToLookasideListEx", "ExFreeToPagedLookasideList", "ExFreeToNPagedLookasideList",
47-
// --- NetBSD pool manager
48-
"pool_put", "pool_cache_put"
49-
]) and
50-
freedArg = 1
51-
or
52-
hasGlobalOrStdName(["HeapFree", "HeapReAlloc"]) and
53-
freedArg = 2
54-
)
20+
"CRYPTO_free", "CRYPTO_secure_free"
21+
]) and
22+
freedArg = 0
23+
or
24+
hasGlobalOrStdName([
25+
// --- Windows Memory Management for Windows Drivers
26+
"ExFreePoolWithTag", "ExDeleteTimer", "IoFreeMdl", "IoFreeWorkItem", "IoFreeErrorLogEntry",
27+
"MmFreeContiguousMemory", "MmFreeContiguousMemorySpecifyCache", "MmFreeNonCachedMemory",
28+
"MmFreeMappingAddress", "MmFreePagesFromMdl", "MmUnmapReservedMapping",
29+
"MmUnmapLockedPages",
30+
// --- Windows Global / Local legacy allocation
31+
"LocalFree", "GlobalFree", "LocalReAlloc", "GlobalReAlloc",
32+
// --- Windows System Services allocation
33+
"VirtualFree",
34+
// --- Windows COM allocation
35+
"CoTaskMemFree", "CoTaskMemRealloc",
36+
// --- Windows Automation
37+
"SysFreeString",
38+
// --- Linux kernel memory allocator
39+
"kmem_free"
40+
]) and
41+
freedArg = 0
42+
or
43+
hasGlobalOrStdName([
44+
// --- Windows Memory Management for Windows Drivers
45+
"ExFreeToLookasideListEx", "ExFreeToPagedLookasideList", "ExFreeToNPagedLookasideList",
46+
// --- NetBSD pool manager
47+
"pool_put", "pool_cache_put"
48+
]) and
49+
freedArg = 1
50+
or
51+
hasGlobalOrStdName(["HeapFree", "HeapReAlloc"]) and
52+
freedArg = 2
5553
}
5654

5755
override int getFreedArg() { result = freedArg }

0 commit comments

Comments
 (0)