Skip to content

Commit 429518b

Browse files
committed
C++: add further FP to test
1 parent 311cf4e commit 429518b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cpp/ql/test/query-tests/Critical/MissingCheckScanf/MissingCheckScanf.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
| test.cpp:404:25:404:25 | u | This variable is read, but may not have been written. It should be guarded by a check that the $@ returns at least 1. | test.cpp:403:6:403:11 | call to sscanf | call to sscanf |
2222
| test.cpp:416:7:416:7 | i | This variable is read, but may not have been written. It should be guarded by a check that the $@ returns at least 1. | test.cpp:413:7:413:11 | call to scanf | call to scanf |
2323
| test.cpp:423:7:423:7 | i | This variable is read, but may not have been written. It should be guarded by a check that the $@ returns at least 1. | test.cpp:420:7:420:11 | call to scanf | call to scanf |
24+
| test.cpp:430:6:430:6 | i | This variable is read, but may not have been written. It should be guarded by a check that the $@ returns at least 1. | test.cpp:429:2:429:6 | call to scanf | call to scanf |

cpp/ql/test/query-tests/Critical/MissingCheckScanf/test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,9 @@ void scan_and_write() {
423423
use(i); // GOOD [FALSE POSITIVE]: variable is overwritten with a default value when scanf fails
424424
}
425425
}
426+
427+
void scan_and_static_variable() {
428+
static int i;
429+
scanf("%d", &i);
430+
use(i); // GOOD [FALSE POSITIVE]: static variables are always 0-initialized
431+
}

0 commit comments

Comments
 (0)