File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
cpp/ql/test/query-tests/Security/CWE/CWE-457/semmle/tests Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 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 ... |
Original file line number Diff line number Diff line change 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 |
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments