Skip to content

Commit c0a1300

Browse files
Improve initializedWthConstants to no longer need a workaround
1 parent f8f21c7 commit c0a1300

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

java/ql/lib/semmle/code/java/security/StaticInitializationVectorQuery.qll

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ private predicate initializedWithConstants(ArrayCreationExpr array) {
99
// creating an array without an initializer, for example `new byte[8]`
1010
not exists(array.getInit())
1111
or
12-
// creating a multidimensional array with an initializer like `{ new byte[8], new byte[16] }`
13-
// This works around https://github.com/github/codeql/issues/6552 -- change me once there is
14-
// a better way to distinguish nested initializers that create zero-filled arrays
15-
// (e.g. `new byte[1]`) from those with an initializer list (`new byte[] { 1 }` or just `{ 1 }`)
16-
array.getInit().getAnInit().getAChildExpr() instanceof IntegerLiteral
17-
or
18-
// creating an array wit an initializer like `new byte[] { 1, 2 }`
19-
forex(Expr element | element = array.getInit().getAnInit() |
12+
initializedWithConstantsHelper(array.getInit())
13+
}
14+
15+
private predicate initializedWithConstantsHelper(ArrayInit arInit) {
16+
forex(Expr element | element = arInit.getAnInit() |
2017
element instanceof CompileTimeConstantExpr
18+
or
19+
initializedWithConstantsHelper(element)
2120
)
2221
}
2322

0 commit comments

Comments
 (0)