mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
C++: Improve ReturnStackAllocatedMemory query
Update the ReturnStackAllocatedMmeory query to not give a false positive for thread_local variables.
This commit is contained in:
@@ -45,6 +45,7 @@ predicate hasNontrivialConversion(Expr e) {
|
||||
from LocalScopeVariable var, VariableAccess va, ReturnStmt r
|
||||
where
|
||||
not var.isStatic() and
|
||||
not var.isThreadLocal() and
|
||||
not var.getUnspecifiedType() instanceof ReferenceType and
|
||||
not r.isFromUninstantiatedTemplate(_) and
|
||||
va = var.getAnAccess() and
|
||||
|
||||
@@ -5,5 +5,4 @@
|
||||
| test.cpp:92:2:92:12 | return ... | May return stack-allocated memory from $@. | test.cpp:89:10:89:11 | mc | mc |
|
||||
| test.cpp:112:2:112:12 | return ... | May return stack-allocated memory from $@. | test.cpp:112:9:112:11 | arr | arr |
|
||||
| test.cpp:119:2:119:19 | return ... | May return stack-allocated memory from $@. | test.cpp:119:11:119:13 | arr | arr |
|
||||
| test.cpp:149:3:149:22 | return ... | May return stack-allocated memory from $@. | test.cpp:149:11:149:21 | threadLocal | threadLocal |
|
||||
| test.cpp:171:3:171:24 | return ... | May return stack-allocated memory from $@. | test.cpp:170:35:170:41 | myLocal | myLocal |
|
||||
|
||||
@@ -146,7 +146,7 @@ char *testArray5()
|
||||
|
||||
int *returnThreadLocal() {
|
||||
thread_local int threadLocal;
|
||||
return &threadLocal; // GOOD [FALSE POSITIVE]
|
||||
return &threadLocal; // GOOD
|
||||
}
|
||||
|
||||
int returnDereferenced() {
|
||||
|
||||
Reference in New Issue
Block a user