Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 627fba8

Browse files
committed
CPP: Improve wording of UnsafeArrayForDAysOfYear.ql.
1 parent db6e290 commit 627fba8

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

cpp/ql/src/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear.ql

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,26 @@ class LeapYearUnsafeDaysOfTheYearArrayType extends ArrayType {
1616
LeapYearUnsafeDaysOfTheYearArrayType() { this.getArraySize() = 365 }
1717
}
1818

19-
from Element element
19+
from Element element, string allocType
2020
where
2121
exists(NewArrayExpr nae |
2222
element = nae and
23-
nae.getAllocatedType() instanceof LeapYearUnsafeDaysOfTheYearArrayType
23+
nae.getAllocatedType() instanceof LeapYearUnsafeDaysOfTheYearArrayType and
24+
allocType = "an array allocation"
2425
)
2526
or
2627
exists(Variable var |
2728
var = element and
28-
var.getType() instanceof LeapYearUnsafeDaysOfTheYearArrayType
29+
var.getType() instanceof LeapYearUnsafeDaysOfTheYearArrayType and
30+
allocType = "an array allocation"
2931
)
3032
or
3133
exists(ConstructorCall cc |
3234
element = cc and
3335
cc.getTarget().hasName("vector") and
34-
cc.getArgument(0).getValue().toInt() = 365
36+
cc.getArgument(0).getValue().toInt() = 365 and
37+
allocType = "a std::vector allocation"
3538
)
3639
select element,
37-
"There is an array or std::vector allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios."
40+
"There is " + allocType +
41+
" with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios."
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| test.cpp:17:6:17:10 | items | There is an array or std::vector allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |
2-
| test.cpp:25:15:25:26 | new[] | There is an array or std::vector allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |
3-
| test.cpp:52:20:52:23 | call to vector | There is an array or std::vector allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |
1+
| test.cpp:17:6:17:10 | items | There is an array allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |
2+
| test.cpp:25:15:25:26 | new[] | There is an array allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |
3+
| test.cpp:52:20:52:23 | call to vector | There is a std::vector allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |

0 commit comments

Comments
 (0)