Program: 168529
Project: 168529
Buggy source:
/** 
 * Generic block counting algorithm.
 * @param usedBlocks whether the algorithm should count used blocks (true)or unused blocks (false).
 * @return the number of matching blocks.
 */
protected synchronized long countBlocks(boolean usedBlocks){
  CommonHFSVolumeHeader vh=parentView.getVolumeHeader();
  byte[] currentBlock=new byte[parentView.physicalBlockSize];
  final long totalBlocks=vh.getTotalBlocks();
  long blockCount=0;
  long matchingBlockCount=0;
  int blockValue=(usedBlocks ? 0x1 : 0x0);
  System.err.println("String_Node_Str" + totalBlocks);
  System.err.println("String_Node_Str" + allocationFileStream.length());
  allocationFileStream.seek(0);
  while (blockCount < totalBlocks) {
    System.err.println("String_Node_Str" + blockCount);
    System.err.println("String_Node_Str" + allocationFileStream.getFilePointer());
    System.out.println("String_Node_Str" + currentBlock.length + "String_Node_Str");
    int bytesRead=allocationFileStream.read(currentBlock);
    System.out.println("String_Node_Str" + bytesRead + "String_Node_Str");
    if (bytesRead >= 0) {
      for (int i=0; i < bytesRead && blockCount < totalBlocks; ++i) {
        byte currentByte=currentBlock[i];
        for (int j=0; j < 8 && blockCount < totalBlocks; ++j) {
          if (((currentByte >> (7 - j)) & 0x1) == blockValue)           ++matchingBlockCount;
          ++blockCount;
        }
      }
    }
 else     throw new RuntimeException("String_Node_Str");
  }
  if (blockCount != totalBlocks)   throw new RuntimeException("String_Node_Str" + blockCount + "String_Node_Str"+ totalBlocks+ "String_Node_Str");
  return matchingBlockCount;
}

Fixed version (ground truth):
/** 
 * Loops through the entire allocation file to count the number of used and free blocks on the volume. The output is placed in two ObjectContainers
 * @param oFreeBlocks (optional) variable where the algorithm stores the free block count.
 * @param oUsedBlocks (optional) variable where the algorithm stores the used block count.
 * @return the total number of allocation blocks on the volume.
 */
public synchronized long countBlocks(ObjectContainer<Long> oFreeBlocks,ObjectContainer<Long> oUsedBlocks){
  CommonHFSVolumeHeader vh=parentView.getVolumeHeader();
  byte[] currentBlock=new byte[128 * 1024];
  final long totalBlocks=vh.getTotalBlocks();
  long blockCount=0;
  long usedBlockCount=0;
  System.err.println("String_Node_Str" + totalBlocks);
  System.err.println("String_Node_Str" + allocationFileStream.length());
  allocationFileStream.seek(0);
  while (blockCount < totalBlocks) {
    System.err.println("String_Node_Str" + blockCount);
    System.err.println("String_Node_Str" + allocationFileStream.getFilePointer());
    System.out.println("String_Node_Str" + currentBlock.length + "String_Node_Str");
    int bytesRead=allocationFileStream.read(currentBlock);
    System.out.println("String_Node_Str" + bytesRead + "String_Node_Str");
    if (bytesRead >= 0) {
      for (int i=0; i < bytesRead && blockCount < totalBlocks; ++i) {
        byte currentByte=currentBlock[i];
        for (int j=0; j < 8 && blockCount < totalBlocks; ++j) {
          ++blockCount;
          if (((currentByte >> (7 - j)) & 0x1) == 0x1)           ++usedBlockCount;
        }
      }
    }
 else     throw new RuntimeException("String_Node_Str");
  }
  if (blockCount != totalBlocks)   throw new RuntimeException("String_Node_Str" + blockCount + "String_Node_Str"+ totalBlocks+ "String_Node_Str");
  if (oFreeBlocks != null)   oFreeBlocks.o=blockCount - usedBlockCount;
  if (oUsedBlocks != null)   oUsedBlocks.o=usedBlockCount;
  return totalBlocks;
}