Skip to content

Commit 85e71c3

Browse files
authored
Merge pull request github#16442 from MathiasVP/add-uninitialized-local-fp
C++: Add `cpp/uninitialized-local` FP
2 parents 8198b1a + 8e95395 commit 85e71c3

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-457/semmle/tests/LoopConditionsConst.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
| test.cpp:416:2:418:2 | for(...;...;...) ... | test.cpp:416:18:416:23 | ... < ... | 1 | i | { ... } | i | return ... |
2323
| test.cpp:424:2:425:2 | for(...;...;...) ... | test.cpp:424:18:424:23 | ... < ... | 1 | i | { ... } | i | return ... |
2424
| test.cpp:433:2:434:2 | for(...;...;...) ... | test.cpp:433:18:433:22 | 0 | 0 | | { ... } | 0 | return ... |
25+
| test.cpp:559:3:564:3 | while (...) ... | test.cpp:559:9:559:15 | call to getBool | | call to getBool | { ... } | call to getBool | ExprStmt |

cpp/ql/test/query-tests/Security/CWE/CWE-457/semmle/tests/UninitializedLocal.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ nodes
1313
| test.cpp:458:6:458:6 | definition of x | semmle.label | definition of x |
1414
| test.cpp:464:6:464:6 | definition of x | semmle.label | definition of x |
1515
| test.cpp:471:6:471:6 | definition of x | semmle.label | definition of x |
16+
| test.cpp:557:15:557:15 | definition of r | semmle.label | definition of r |
1617
#select
1718
| test.cpp:12:6:12:8 | foo | test.cpp:11:6:11:8 | definition of foo | test.cpp:11:6:11:8 | definition of foo | The variable $@ may not be initialized at this access. | test.cpp:11:6:11:8 | foo | foo |
1819
| test.cpp:113:6:113:8 | foo | test.cpp:111:6:111:8 | definition of foo | test.cpp:111:6:111:8 | definition of foo | The variable $@ may not be initialized at this access. | test.cpp:111:6:111:8 | foo | foo |
@@ -27,3 +28,4 @@ nodes
2728
| test.cpp:460:7:460:7 | x | test.cpp:458:6:458:6 | definition of x | test.cpp:458:6:458:6 | definition of x | The variable $@ may not be initialized at this access. | test.cpp:458:6:458:6 | x | x |
2829
| test.cpp:467:2:467:2 | x | test.cpp:464:6:464:6 | definition of x | test.cpp:464:6:464:6 | definition of x | The variable $@ may not be initialized at this access. | test.cpp:464:6:464:6 | x | x |
2930
| test.cpp:474:7:474:7 | x | test.cpp:471:6:471:6 | definition of x | test.cpp:471:6:471:6 | definition of x | The variable $@ may not be initialized at this access. | test.cpp:471:6:471:6 | x | x |
31+
| test.cpp:567:7:567:7 | r | test.cpp:557:15:557:15 | definition of r | test.cpp:557:15:557:15 | definition of r | The variable $@ may not be initialized at this access. | test.cpp:557:15:557:15 | r | r |

cpp/ql/test/query-tests/Security/CWE/CWE-457/semmle/tests/test.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Semmle test cases for rule CWE-457.
22

3-
void use(int data);
3+
void use(...);
44

55
void test1() {
66
int foo = 1;
@@ -544,4 +544,25 @@ class StaticMethodClass{
544544
int static_method_false_positive(){
545545
StaticMethodClass *t;
546546
int i = t->get(); // GOOD: the `get` method is static and this is equivalent to StaticMethodClass::get()
547+
}
548+
549+
struct LinkedList
550+
{
551+
LinkedList* next;
552+
};
553+
554+
bool getBool();
555+
556+
void test45() {
557+
LinkedList *r, *s, **rP = &r;
558+
559+
while(getBool())
560+
{
561+
s = new LinkedList;
562+
*rP = s;
563+
rP = &s->next;
564+
}
565+
566+
*rP = NULL;
567+
use(r); // GOOD [FALSE POSITIVE]
547568
}

0 commit comments

Comments
 (0)