Примеры ошибок, обнаруженных с помощью диагностики V6025
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--;
}
....
}
....
}
jMonkeyEngine
V6025 Index 'i' is out of bounds. FbxMesh.java(336)
private List<Geometry> createGeometries() throws IOException {
....
iCount = vCount = srcVertexCount;
vertexMap = new ArrayList<>(vCount); // <=
indexMap = new ArrayList<>(vCount);
reverseVertexMap = new ArrayList<>(vCount);
for (int i = 0; i < vCount; ++i) {
vertexMap.set(i, i); // <=
indexMap.set(i, i);
List<Integer> l = new ArrayList<>(1);
l.add(i);
reverseVertexMap.add(l);
}
....
}
GeoGebra
V6025 Index 'index - 1' is out of bounds. LayerManager.java(393)
private void updateOrdering(GeoElement geo, ObjectMovement movement) {
....
switch (movement) {
....
case FRONT:
....
if (index == firstIndex) {
if (index != 0) {
geo.setOrdering(orderingDepthMidpoint(index));
}
else {
geo.setOrdering(drawingOrder.get(index - 1).getOrdering() - 1);
}
}
....
}
....
}
In the else block the variable index is guaranteed to be zero and passing index - 1 to the get method will result in IndexOutOfBoundsException