mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #1615 from geoffw0/exprowninit
CPP: Test + workaround for UseInOwnInitializer.ql
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
| No space for zero terminator (`cpp/no-space-for-terminator`) | Fewer false positive results | False positives involving strings that are not null-terminated have been excluded. |
|
||||
| Suspicious pointer scaling (`cpp/suspicious-pointer-scaling`) | Lower precision | The precision of this query has been reduced to "medium". This coding pattern is used intentionally and safely in a number of real-world projects. Results are no longer displayed on LGTM unless you choose to display them. |
|
||||
| Non-constant format string (`cpp/non-constant-format`) | Fewer false positive results | Rewritten using the taint-tracking library. |
|
||||
| Variable used in its own initializer (`cpp/use-in-own-initializer`) | Fewer false positive results | False positives for constant variables with the same name in different namespaces have been removed. |
|
||||
|
||||
## Changes to QL libraries
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ where va.initializesItself(v, init)
|
||||
exists (CrementOperation crement | crement.getAnOperand() = va)
|
||||
)
|
||||
and not va.isUnevaluated()
|
||||
and not v.isConst()
|
||||
and not (
|
||||
va.getParent() = init and
|
||||
exists(MacroInvocation mi |
|
||||
|
||||
@@ -66,3 +66,26 @@ void test11() {
|
||||
void test12() {
|
||||
self_initialize(int, x); // GOOD (statement is from a macro)
|
||||
}
|
||||
|
||||
namespace ns1
|
||||
{
|
||||
const int v2 = 1;
|
||||
const int v4 = 1;
|
||||
const int v6 = 1;
|
||||
};
|
||||
|
||||
namespace ns2
|
||||
{
|
||||
const int v1 = ns1::v2; // GOOD
|
||||
const int v2 = ns1::v2; // GOOD [produces INVALID_KEY trap warning]
|
||||
};
|
||||
|
||||
const int v3 = ns1::v4; // GOOD
|
||||
const int v4 = ns1::v4; // GOOD
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
const int v5 = ns1::v6 + 1; // GOOD
|
||||
const int v6 = ns1::v6 + 1; // GOOD [produces INVALID_KEY trap warning]
|
||||
const int v7 = ns3::v7; // BAD [NOT DETECTED]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user