Examples of errors detected by the V6025 diagnostic
V6025. Possibly index is out of bound.
Elasticsearch
V6025 Possibly index '(int) x' is out of bounds. BCrypt.java(431)
private static byte char64(char x) {
if ((int)x < 0 || (int)x > index_64.length)
return -1;
return index_64[(int)x];
}
Bouncy Castle
V6025 Possibly index 'i' is out of bounds. HSSTests.java(384)
public void testVectorsFromReference() throws Exception {
List<LMSigParameters> lmsParameters = new ArrayList<LMSigParameters>();
List<LMOtsParameters> lmOtsParameters = new ArrayList<LMOtsParameters>();
....
for (String line : lines) {
....
if (line.startsWith("Depth:")) {
....
} else if (line.startsWith("LMType:")) {
....
lmsParameters.add(LMSigParameters.getParametersForType(typ));
} else if (line.startsWith("LMOtsType:")) {
....
lmOtsParameters.add(LMOtsParameters.getParametersForType(typ));
}
}
....
for (int i = 0; i != lmsParameters.size(); i++) {
lmsParams.add(new LMSParameters(lmsParameters.get(i),
lmOtsParameters.get(i)));
}
}
ELKI
V6025 Index '1' is out of bounds. GeneratorStatic.java(104)
@Override
public double[] computeMean() {
// Not supported except for singletons.
return points.size() == 1 ? points.get(1) : null;
}
Rhino
V6025 Index 'sig1.length - 1' is out of bounds. NativeJavaMethod.java(461)
public class NativeJavaMethod extends BaseFunction {
private static int preferSignature(Object[] args,
Class<?>[] sig1,
boolean vararg1,
Class<?>[] sig2,
boolean vararg2) {
int totalPreference = 0;
for (int j = 0; j < args.length; j++) {
Class<?> type1 = vararg1 &&
j >= sig1.length ? sig1[sig1.length - 1] // <=
: sig1[j];
Class<?> type2 = vararg2 &&
j >= sig2.length ? sig2[sig2.length - 1] // <=
: sig2[j];
....
}
return totalPreference;
}
}
Rhino
V6025 Index 'sig2.length - 1' is out of bounds. NativeJavaMethod.java(462)
public class NativeJavaMethod extends BaseFunction {
private static int preferSignature(Object[] args,
Class<?>[] sig1,
boolean vararg1,
Class<?>[] sig2,
boolean vararg2) {
int totalPreference = 0;
for (int j = 0; j < args.length; j++) {
Class<?> type1 = vararg1 &&
j >= sig1.length ? sig1[sig1.length - 1] // <=
: sig1[j];
Class<?> type2 = vararg2 &&
j >= sig2.length ? sig2[sig2.length - 1] // <=
: sig2[j];
....
}
return totalPreference;
}
}
Rhino
V6025 Possibly index 'last - 1' is out of bounds. SuperBlock.java(50)
final class SuperBlock {
....
int[] getTrimmedLocals() {
int last = locals.length - 1;
while (last >= 0
&& locals[last] == TypeInfo.TOP
&& !TypeInfo.isTwoWords(locals[last - 1])) { // <=
last--;
}
....
}
....
}