Merge pull request #1615 from geoffw0/exprowninit

CPP: Test + workaround for UseInOwnInitializer.ql
This commit is contained in:
Robert Marsh
2019-07-24 12:13:24 -07:00
committed by GitHub
3 changed files with 25 additions and 0 deletions

View File

@@ -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

View File

@@ -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 |

View File

@@ -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]
};