Program: 168545
Project: 168545
Buggy source:
public void loadFS(ReadableRandomAccessStream fsFile,String displayName){
  int blockSize=0x200;
  int ddrBlockSize;
  long fsOffset;
  long fsLength;
  PartitionSystemRecognizer psRec=new PartitionSystemRecognizer(fsFile);
  PartitionSystem partSys=psRec.getPartitionSystem();
  if (partSys != null) {
    Partition[] partitions=partSys.getUsedPartitionEntries();
    if (partitions.length == 0) {
      fsOffset=0;
      fsLength=fsFile.length();
    }
 else {
      Object selectedValue;
      int firstPreferredPartition=0;
      for (int i=0; i < partitions.length; ++i) {
        Partition p=partitions[i];
        if (p.getType() == Partition.PartitionType.APPLE_HFS) {
          firstPreferredPartition=i;
          break;
        }
      }
      while (true) {
        selectedValue=JOptionPane.showInputDialog(this,"String_Node_Str","String_Node_Str" + partSys.getLongName() + "String_Node_Str",JOptionPane.QUESTION_MESSAGE,null,partitions,partitions[firstPreferredPartition]);
        if (selectedValue != null && selectedValue instanceof Partition) {
          Partition selectedPartition=(Partition)selectedValue;
          if (selectedPartition.getType() == Partition.PartitionType.APPLE_HFS)           break;
 else           JOptionPane.showMessageDialog(this,"String_Node_Str" + selectedPartition.getType() + "String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
        }
 else         return;
      }
      if (selectedValue instanceof Partition) {
        Partition selectedPartition=(Partition)selectedValue;
        fsOffset=selectedPartition.getStartOffset();
        fsLength=selectedPartition.getLength();
      }
 else       throw new RuntimeException("String_Node_Str");
    }
  }
 else {
    fsOffset=0;
    fsLength=fsFile.length();
  }
  FileSystemRecognizer fsr=new FileSystemRecognizer(fsFile,fsOffset);
  FileSystemRecognizer.FileSystemType fsType=fsr.detectFileSystem();
  if (fsType == FileSystemRecognizer.FileSystemType.HFS_WRAPPED_HFS_PLUS) {
    byte[] mdbData=new byte[HFSPlusWrapperMDB.STRUCTSIZE];
    fsFile.seek(fsOffset + 1024);
    fsFile.read(mdbData);
    HFSPlusWrapperMDB mdb=new HFSPlusWrapperMDB(mdbData,0);
    ExtDescriptor xd=mdb.getDrEmbedExtent();
    int hfsBlockSize=mdb.getDrAlBlkSiz();
    fsOffset+=mdb.getDrAlBlSt() * 512 + xd.getXdrStABN() * hfsBlockSize;
    fsr=new FileSystemRecognizer(fsFile,fsOffset);
    fsType=fsr.detectFileSystem();
  }
  if (fsType == FileSystemRecognizer.FileSystemType.HFS_PLUS || fsType == FileSystemRecognizer.FileSystemType.HFSX || fsType == FileSystemRecognizer.FileSystemType.HFS) {
    if (fsHandler != null) {
      fsHandler.close();
    }
    final FileSystemMajorType fsMajorType;
switch (fsType) {
case HFS:
      fsMajorType=FileSystemMajorType.APPLE_HFS;
    break;
case HFS_PLUS:
  fsMajorType=FileSystemMajorType.APPLE_HFS_PLUS;
break;
case HFSX:
fsMajorType=FileSystemMajorType.APPLE_HFSX;
break;
default :
fsMajorType=null;
break;
}
FileSystemHandlerFactory factory=fsMajorType.createDefaultHandlerFactory();
if (factory.isSupported(StandardAttribute.CACHING_ENABLED)) {
factory.getCreateAttributes().setBooleanAttribute(StandardAttribute.CACHING_ENABLED,toggleCachingItem.getState());
}
System.err.println("String_Node_Str" + fsFile);
System.err.println("String_Node_Str");
ReadableConcatenatedStream stage1=new ReadableConcatenatedStream(fsFile,fsOffset,fsLength);
System.err.println("String_Node_Str");
ReadableStreamDataLocator stage2=new ReadableStreamDataLocator(stage1);
System.err.println("String_Node_Str");
fsHandler=(HFSCommonFileSystemHandler)factory.createHandler(stage2);
FSFolder rootRecord=fsHandler.getRoot();
populateFilesystemGUI(rootRecord);
setTitle(TITLE_STRING + "String_Node_Str" + displayName+ "String_Node_Str");
}
 else JOptionPane.showMessageDialog(this,"String_Node_Str" + "String_Node_Str" + FileSystemRecognizer.FileSystemType.HFS_PLUS + "String_Node_Str"+ "String_Node_Str"+ FileSystemRecognizer.FileSystemType.HFSX+ "String_Node_Str"+ "String_Node_Str"+ FileSystemRecognizer.FileSystemType.HFS_WRAPPED_HFS_PLUS+ "String_Node_Str"+ "String_Node_Str"+ fsType+ "String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
}

Fixed version (ground truth):
public void loadFS(ReadableRandomAccessStream fsFile,String displayName){
  int blockSize=0x200;
  int ddrBlockSize;
  long fsOffset;
  long fsLength;
  PartitionSystemRecognizer psRec=new PartitionSystemRecognizer(fsFile);
  PartitionSystem partSys=psRec.getPartitionSystem();
  if (partSys != null) {
    Partition[] partitions=partSys.getUsedPartitionEntries();
    if (partitions.length == 0) {
      fsOffset=0;
      fsLength=fsFile.length();
    }
 else {
      Object selectedValue;
      int firstPreferredPartition=0;
      for (int i=0; i < partitions.length; ++i) {
        Partition p=partitions[i];
        if (p.getType() == Partition.PartitionType.APPLE_HFS) {
          firstPreferredPartition=i;
          break;
        }
      }
      while (true) {
        selectedValue=JOptionPane.showInputDialog(this,"String_Node_Str","String_Node_Str" + partSys.getLongName() + "String_Node_Str",JOptionPane.QUESTION_MESSAGE,null,partitions,partitions[firstPreferredPartition]);
        if (selectedValue != null && selectedValue instanceof Partition) {
          Partition selectedPartition=(Partition)selectedValue;
          if (selectedPartition.getType() == Partition.PartitionType.APPLE_HFS) {
            break;
          }
 else {
            JOptionPane.showMessageDialog(this,"String_Node_Str" + selectedPartition.getType() + "String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
          }
        }
 else {
          return;
        }
      }
      if (selectedValue instanceof Partition) {
        Partition selectedPartition=(Partition)selectedValue;
        fsOffset=selectedPartition.getStartOffset();
        fsLength=selectedPartition.getLength();
      }
 else {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
 else {
    fsOffset=0;
    fsLength=fsFile.length();
  }
  FileSystemRecognizer fsr=new FileSystemRecognizer(fsFile,fsOffset);
  FileSystemRecognizer.FileSystemType fsType=fsr.detectFileSystem();
  if (fsType == FileSystemRecognizer.FileSystemType.HFS_WRAPPED_HFS_PLUS) {
    byte[] mdbData=new byte[HFSPlusWrapperMDB.STRUCTSIZE];
    fsFile.seek(fsOffset + 1024);
    fsFile.read(mdbData);
    HFSPlusWrapperMDB mdb=new HFSPlusWrapperMDB(mdbData,0);
    ExtDescriptor xd=mdb.getDrEmbedExtent();
    int hfsBlockSize=mdb.getDrAlBlkSiz();
    fsOffset+=mdb.getDrAlBlSt() * 512 + xd.getXdrStABN() * hfsBlockSize;
    fsr=new FileSystemRecognizer(fsFile,fsOffset);
    fsType=fsr.detectFileSystem();
  }
  if (fsType == FileSystemRecognizer.FileSystemType.HFS_PLUS || fsType == FileSystemRecognizer.FileSystemType.HFSX || fsType == FileSystemRecognizer.FileSystemType.HFS) {
    if (fsHandler != null) {
      fsHandler.close();
    }
    final FileSystemMajorType fsMajorType;
switch (fsType) {
case HFS:
      fsMajorType=FileSystemMajorType.APPLE_HFS;
    break;
case HFS_PLUS:
  fsMajorType=FileSystemMajorType.APPLE_HFS_PLUS;
break;
case HFSX:
fsMajorType=FileSystemMajorType.APPLE_HFSX;
break;
default :
fsMajorType=null;
break;
}
FileSystemHandlerFactory factory=fsMajorType.createDefaultHandlerFactory();
if (factory.isSupported(StandardAttribute.CACHING_ENABLED)) {
factory.getCreateAttributes().setBooleanAttribute(StandardAttribute.CACHING_ENABLED,toggleCachingItem.getState());
}
System.err.println("String_Node_Str" + fsFile);
System.err.println("String_Node_Str");
ReadableConcatenatedStream stage1=new ReadableConcatenatedStream(fsFile,fsOffset,fsLength);
System.err.println("String_Node_Str");
this.fsDataLocator=new ReadableStreamDataLocator(stage1);
System.err.println("String_Node_Str");
fsHandler=(HFSCommonFileSystemHandler)factory.createHandler(fsDataLocator);
FSFolder rootRecord=fsHandler.getRoot();
populateFilesystemGUI(rootRecord);
setTitle(TITLE_STRING + "String_Node_Str" + displayName+ "String_Node_Str");
}
 else {
JOptionPane.showMessageDialog(this,"String_Node_Str" + "String_Node_Str" + FileSystemRecognizer.FileSystemType.HFS_PLUS + "String_Node_Str"+ "String_Node_Str"+ FileSystemRecognizer.FileSystemType.HFSX+ "String_Node_Str"+ "String_Node_Str"+ FileSystemRecognizer.FileSystemType.HFS_WRAPPED_HFS_PLUS+ "String_Node_Str"+ "String_Node_Str"+ fsType+ "String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
}
}