Skip to content

Commit 7fca220

Browse files
committed
CPP: Fix UncheckedLeapYearAfterYearModification FPs.
1 parent cff3f9b commit 7fca220

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

cpp/ql/src/Likely Bugs/Leap Year/LeapYear.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
9191
mulBy100.getAChild().getValue().toInt() = 100 )))
9292
or exists( BinaryArithmeticOperation bao |
9393
bao = op.getAnOperand()
94+
// we're specifically interested in calculations that update the existing
95+
// value (like `x = x + 1`), so look for a child `YearFieldAccess`.
96+
and bao.getAChild*() instanceof YearFieldAccess
9497
and not ( bao.getAChild().getValue().toInt() = 1900
9598
or bao.getAChild().getValue().toInt() = 2000
9699
or bao.getAChild().getValue().toInt() = 1980

cpp/ql/test/query-tests/Likely Bugs/Leap Year/UncheckedLeapYearAfterYearModification/UncheckedLeapYearAfterYearModification.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
| test.cpp:636:11:636:17 | tm_year | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:56:6:56:12 | tm_year | tm_year | test.cpp:628:12:628:19 | timeinfo | timeinfo |
1010
| test.cpp:640:5:640:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:629:13:629:14 | st | st |
1111
| test.cpp:642:5:642:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:629:13:629:14 | st | st |
12-
| test.cpp:677:5:677:11 | tm_year | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:56:6:56:12 | tm_year | tm_year | test.cpp:664:12:664:12 | t | t |

0 commit comments

Comments
 (0)