Program: 19822
Project: 19822
Buggy source:
/** 
 * Converts a little-endian byte array into an array of doubles.  Each consecutive bytes of a float are converted into a double, and becomes the next element in the double array. The number of bytes in the double is specified as an argument. The size of the returned array is (data.length/bytesPerValue).
 * @param data a byte array
 * @param offset which byte to start from
 * @param length how many bytes to convert
 * @param bytesPerValue the number of bytes per value
 * @param signed whether the data is signed
 * @return a double array, or <code>null</code> if byteArray is of zerolength
 * @throws java.lang.ArrayIndexOutOfBoundsException
 */
public static final double[] littleEndianBytesToValues(byte[] data,int offset,int length,int bytesPerValue,boolean signed) throws ArrayIndexOutOfBoundsException {
  if (0 < length && (offset + length) <= data.length) {
    double[] doubleArray=new double[length / bytesPerValue];
    if (bytesPerValue == 2) {
      if (signed) {
        for (int i=offset, j=0; i < length; j++) {
          short temp=(short)((0x000000FF & data[i++]) | (data[i++] << 8));
          doubleArray[j]=(double)temp;
        }
      }
 else {
        for (int i=offset, j=0; i < length; j++) {
          int temp=(int)((0x000000FF & data[i++]) | (data[i++] << 8));
          doubleArray[j]=(double)temp;
        }
      }
    }
 else     if (bytesPerValue == 1) {
      for (int i=0; i < doubleArray.length; i++) {
        doubleArray[i]=data[i];
      }
    }
 else {
      throw new Error("String_Node_Str" + bytesPerValue);
    }
    return doubleArray;
  }
 else {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str" + offset + "String_Node_Str"+ length+ "String_Node_Str"+ data.length);
  }
}

Fixed version (ground truth):
/** 
 * Converts a little-endian byte array into an array of doubles.  Each consecutive bytes of a float are converted into a double, and becomes the next element in the double array. The number of bytes in the double is specified as an argument. The size of the returned array is (data.length/bytesPerValue).
 * @param data a byte array
 * @param offset which byte to start from
 * @param length how many bytes to convert
 * @param bytesPerValue the number of bytes per value
 * @param signed whether the data is signed
 * @return a double array, or <code>null</code> if byteArray is of zerolength
 * @throws java.lang.ArrayIndexOutOfBoundsException
 */
public static final double[] littleEndianBytesToValues(byte[] data,int offset,int length,int bytesPerValue,boolean signedData) throws ArrayIndexOutOfBoundsException {
  if (0 < length && (offset + length) <= data.length) {
    assert(length % bytesPerValue == 0);
    double[] doubleArray=new double[length / bytesPerValue];
    int i=offset + bytesPerValue - 1;
    for (int j=0; j < doubleArray.length; j++) {
      int val=(int)data[i--];
      if (!signedData) {
        val&=0xff;
      }
      for (int c=1; c < bytesPerValue; c++) {
        int temp=(int)data[i--] & 0xff;
        val=(val << 8) + temp;
      }
      i+=(bytesPerValue * 2);
      doubleArray[j]=(double)val;
    }
    return doubleArray;
  }
 else {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str" + offset + "String_Node_Str"+ length+ "String_Node_Str"+ data.length);
  }
}