Program: 19821
Project: 19821
Buggy source:
/** 
 * Converts a byte array into an array of doubles. Each consecutive bytes in the byte array are converted into a double,  and becomes the next element in the double array. The size of the returned array is (length/bytesPerValue).  Currently, only 1 byte (8-bit) or 2 bytes (16-bit) samples are supported.
 * @param byteArray 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 signedData 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[] bytesToValues(byte[] byteArray,int offset,int length,int bytesPerValue,boolean signedData) throws ArrayIndexOutOfBoundsException {
  if (0 < length && (offset + length) <= byteArray.length) {
    int doubleLength=length / bytesPerValue;
    double[] doubleArray=new double[doubleLength];
    if (bytesPerValue == 2) {
      if (!signedData) {
        for (int i=offset, j=0; j < doubleLength; j++) {
          int temp=(int)byteArray[i++];
          temp=(temp << 8);
          temp|=(int)(0x000000FF & byteArray[i++]);
          doubleArray[j]=(double)temp;
        }
      }
 else {
        for (int i=offset, j=0; j < doubleLength; j++) {
          short temp=(short)(byteArray[i++] << 8);
          temp|=(short)(0x00FF & byteArray[i++]);
          doubleArray[j]=(double)temp;
        }
      }
    }
 else     if (bytesPerValue == 1) {
      for (int i=offset; i < doubleLength; i++) {
        doubleArray[i]=(double)byteArray[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"+ byteArray.length);
  }
}

Fixed version (ground truth):
/** 
 * Converts a big-endian byte array into an array of doubles. Each consecutive bytes in the byte array are converted into a double,  and becomes the next element in the double array. The size of the returned array is (length/bytesPerValue).  Currently, only 1 byte (8-bit) or 2 bytes (16-bit) samples are supported.
 * @param byteArray 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 signedData 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[] bytesToValues(byte[] byteArray,int offset,int length,int bytesPerValue,boolean signedData) throws ArrayIndexOutOfBoundsException {
  if (0 < length && (offset + length) <= byteArray.length) {
    assert(length % bytesPerValue == 0);
    double[] doubleArray=new double[length / bytesPerValue];
    int i=offset;
    for (int j=0; j < doubleArray.length; j++) {
      int val=(int)byteArray[i++];
      if (!signedData) {
        val&=0xff;
      }
      for (int c=1; c < bytesPerValue; c++) {
        int temp=(int)byteArray[i++] & 0xff;
        val=(val << 8) + temp;
      }
      doubleArray[j]=(double)val;
    }
    return doubleArray;
  }
 else {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str" + offset + "String_Node_Str"+ length+ "String_Node_Str"+ byteArray.length);
  }
}