Skip to content

Commit c94edcf

Browse files
committed
Add failing test case
1 parent fb72602 commit c94edcf

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

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

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,4 +1052,20 @@ ATime_HrGetSysTime(SYSTEMTIME *pst)
10521052
// pst->wMinute = static_cast<WORD>(m_lMinute);
10531053
// pst->wSecond = static_cast<WORD>(m_lSecond);
10541054
// pst->wMilliseconds = 0;
1055+
}
1056+
1057+
/**
1058+
* Negative Case - Anti-pattern 1: [year ±n, month, day]
1059+
* Modification of SYSTEMTIME struct by copying from another struct, but no arithmetic is performed.
1060+
*/
1061+
void fp_daymonth_guard(){
1062+
SYSTEMTIME st;
1063+
FILETIME ft;
1064+
GetSystemTime(&st);
1065+
1066+
st.wYear++;
1067+
1068+
st.wDay = st.wMonth == 2 && st.wDay == 29 ? 28 : st.wDay;
1069+
1070+
SystemTimeToFileTime(&st, &ft);
10551071
}

0 commit comments

Comments
 (0)