Program: 92935
Project: 92935
Buggy source:
private void processTag(@NotNull Directory directory,int tagType,int tagValueOffset,int componentCount,int formatCode,@NotNull final BufferReader reader) throws BufferBoundsException {
switch (formatCode) {
case FMT_UNDEFINED:
    directory.setByteArray(tagType,reader.getBytes(tagValueOffset,componentCount));
  break;
case FMT_STRING:
String string=reader.getNullTerminatedString(tagValueOffset,componentCount);
directory.setString(tagType,string);
break;
case FMT_SRATIONAL:
case FMT_URATIONAL:
if (componentCount == 1) {
directory.setRational(tagType,new Rational(reader.getInt32(tagValueOffset),reader.getInt32(tagValueOffset + 4)));
}
 else if (componentCount > 1) {
Rational[] rationals=new Rational[componentCount];
for (int i=0; i < componentCount; i++) rationals[i]=new Rational(reader.getInt32(tagValueOffset + (8 * i)),reader.getInt32(tagValueOffset + 4 + (8 * i)));
directory.setRationalArray(tagType,rationals);
}
break;
case FMT_SBYTE:
case FMT_BYTE:
if (componentCount == 1) {
directory.setInt(tagType,reader.getUInt8(tagValueOffset));
}
 else {
int[] bytes=new int[componentCount];
for (int i=0; i < componentCount; i++) bytes[i]=reader.getUInt8(tagValueOffset + i);
directory.setIntArray(tagType,bytes);
}
break;
case FMT_SINGLE:
if (componentCount == 1) {
directory.setFloat(tagType,reader.getFloat32(tagValueOffset));
}
 else {
float[] floats=new float[componentCount];
for (int i=0; i < componentCount; i++) floats[i]=reader.getFloat32(tagValueOffset + (i * 4));
directory.setFloatArray(tagType,floats);
}
break;
case FMT_DOUBLE:
if (componentCount == 1) {
directory.setDouble(tagType,reader.getDouble64(tagValueOffset));
}
 else {
double[] doubles=new double[componentCount];
for (int i=0; i < componentCount; i++) doubles[i]=reader.getDouble64(tagValueOffset + (i * 4));
directory.setDoubleArray(tagType,doubles);
}
break;
case FMT_USHORT:
case FMT_SSHORT:
if (componentCount == 1) {
int i=reader.getUInt16(tagValueOffset);
directory.setInt(tagType,i);
}
 else {
int[] ints=new int[componentCount];
for (int i=0; i < componentCount; i++) ints[i]=reader.getUInt16(tagValueOffset + (i * 2));
directory.setIntArray(tagType,ints);
}
break;
case FMT_SLONG:
case FMT_ULONG:
if (componentCount == 1) {
int i=reader.getInt32(tagValueOffset);
directory.setInt(tagType,i);
}
 else {
int[] ints=new int[componentCount];
for (int i=0; i < componentCount; i++) ints[i]=reader.getInt32(tagValueOffset + (i * 4));
directory.setIntArray(tagType,ints);
}
break;
default :
directory.addError("String_Node_Str" + formatCode + "String_Node_Str"+ tagType);
}
}

Fixed version (ground truth):
private void processTag(@NotNull Directory directory,int tagType,int tagValueOffset,int componentCount,int formatCode,@NotNull final BufferReader reader) throws BufferBoundsException {
switch (formatCode) {
case FMT_UNDEFINED:
    directory.setByteArray(tagType,reader.getBytes(tagValueOffset,componentCount));
  break;
case FMT_STRING:
String string=reader.getNullTerminatedString(tagValueOffset,componentCount);
directory.setString(tagType,string);
break;
case FMT_SRATIONAL:
if (componentCount == 1) {
directory.setRational(tagType,new Rational(reader.getInt32(tagValueOffset),reader.getInt32(tagValueOffset + 4)));
}
 else if (componentCount > 1) {
Rational[] rationals=new Rational[componentCount];
for (int i=0; i < componentCount; i++) rationals[i]=new Rational(reader.getInt32(tagValueOffset + (8 * i)),reader.getInt32(tagValueOffset + 4 + (8 * i)));
directory.setRationalArray(tagType,rationals);
}
break;
case FMT_URATIONAL:
if (componentCount == 1) {
directory.setRational(tagType,new Rational(reader.getUInt32(tagValueOffset),reader.getUInt32(tagValueOffset + 4)));
}
 else if (componentCount > 1) {
Rational[] rationals=new Rational[componentCount];
for (int i=0; i < componentCount; i++) rationals[i]=new Rational(reader.getUInt32(tagValueOffset + (8 * i)),reader.getUInt32(tagValueOffset + 4 + (8 * i)));
directory.setRationalArray(tagType,rationals);
}
break;
case FMT_SBYTE:
case FMT_BYTE:
if (componentCount == 1) {
directory.setInt(tagType,reader.getUInt8(tagValueOffset));
}
 else {
int[] bytes=new int[componentCount];
for (int i=0; i < componentCount; i++) bytes[i]=reader.getUInt8(tagValueOffset + i);
directory.setIntArray(tagType,bytes);
}
break;
case FMT_SINGLE:
if (componentCount == 1) {
directory.setFloat(tagType,reader.getFloat32(tagValueOffset));
}
 else {
float[] floats=new float[componentCount];
for (int i=0; i < componentCount; i++) floats[i]=reader.getFloat32(tagValueOffset + (i * 4));
directory.setFloatArray(tagType,floats);
}
break;
case FMT_DOUBLE:
if (componentCount == 1) {
directory.setDouble(tagType,reader.getDouble64(tagValueOffset));
}
 else {
double[] doubles=new double[componentCount];
for (int i=0; i < componentCount; i++) doubles[i]=reader.getDouble64(tagValueOffset + (i * 4));
directory.setDoubleArray(tagType,doubles);
}
break;
case FMT_USHORT:
case FMT_SSHORT:
if (componentCount == 1) {
int i=reader.getUInt16(tagValueOffset);
directory.setInt(tagType,i);
}
 else {
int[] ints=new int[componentCount];
for (int i=0; i < componentCount; i++) ints[i]=reader.getUInt16(tagValueOffset + (i * 2));
directory.setIntArray(tagType,ints);
}
break;
case FMT_SLONG:
case FMT_ULONG:
if (componentCount == 1) {
int i=reader.getInt32(tagValueOffset);
directory.setInt(tagType,i);
}
 else {
int[] ints=new int[componentCount];
for (int i=0; i < componentCount; i++) ints[i]=reader.getInt32(tagValueOffset + (i * 4));
directory.setIntArray(tagType,ints);
}
break;
default :
directory.addError("String_Node_Str" + formatCode + "String_Node_Str"+ tagType);
}
}