Skip to content

Commit 536adaa

Browse files
committed
CPP: Additional test cases.
1 parent 52b68a7 commit 536adaa

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
| test.cpp:374:2:376:17 | do (...) ... | test.cpp:376:11:376:15 | 0 | | do (...) ... | { ... } | { ... } | return ... |
1919
| test.cpp:384:2:386:2 | while (...) ... | test.cpp:384:9:384:12 | 1 | 1 | 1 | { ... } | | return ... |
2020
| test.cpp:394:2:396:2 | while (...) ... | test.cpp:394:9:394:21 | ... , ... | | { ... } | { ... } | | |
21+
| test.cpp:404:3:408:3 | while (...) ... | test.cpp:404:10:404:13 | loop | 1 | loop | { ... } | | |
22+
| test.cpp:416:2:418:2 | for(...;...;...) ... | test.cpp:416:18:416:23 | ... < ... | 1 | i | { ... } | i | return ... |
23+
| test.cpp:424:2:425:2 | for(...;...;...) ... | test.cpp:424:18:424:23 | ... < ... | 1 | i | { ... } | i | return ... |
24+
| test.cpp:433:2:434:2 | for(...;...;...) ... | test.cpp:433:18:433:22 | 0 | 0 | | { ... } | 0 | return ... |

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
| test.cpp:336:10:336:10 | a | The variable $@ may not be initialized here. | test.cpp:333:7:333:7 | a | a |
1313
| test.cpp:369:10:369:10 | a | The variable $@ may not be initialized here. | test.cpp:358:7:358:7 | a | a |
1414
| test.cpp:378:9:378:11 | val | The variable $@ may not be initialized here. | test.cpp:359:6:359:8 | val | val |
15+
| test.cpp:410:9:410:11 | val | The variable $@ may not be initialized here. | test.cpp:401:6:401:8 | val | val |
16+
| test.cpp:417:10:417:10 | j | The variable $@ may not be initialized here. | test.cpp:414:9:414:9 | j | j |
17+
| test.cpp:436:9:436:9 | j | The variable $@ may not be initialized here. | test.cpp:431:9:431:9 | j | j |

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,43 @@ int test33() {
395395
return val; // GOOD
396396
}
397397
}
398+
399+
int test34() {
400+
bool loop = true;
401+
int val;
402+
403+
{
404+
while (loop)
405+
{
406+
val = 1;
407+
loop = false;
408+
}
409+
}
410+
return val; // GOOD [FALSE POSITIVE]
411+
}
412+
413+
int test35() {
414+
int i, j;
415+
416+
for (int i = 0; i < 10; i++, j = 1) {
417+
return j; // BAD
418+
}
419+
}
420+
421+
int test36() {
422+
int i, j;
423+
424+
for (int i = 0; i < 10; i++, j = 1) {
425+
}
426+
427+
return j; // GOOD
428+
}
429+
430+
int test38() {
431+
int i, j;
432+
433+
for (int i = 0; false; i++, j = 1) {
434+
}
435+
436+
return j; // BAD
437+
}

0 commit comments

Comments
 (0)