Program: 74986
Project: 74986
Buggy source:
/** 
 * Traverse the directory tree recursively and generate .moml index files.
 * @param inputSuffix Suffix for the input files to look for.
 * @param outputFilename Name of the index file to generate.
 * @param root Root dir of the input files.
 * @param currentDir The current directory in this call to proc().
 * @exception Exception If internal error (duplicate file foundor invalid currentDir name.
 */
public static void proc(final String inputSuffix,final String outputFilename,String root,String currentDir) throws Exception {
  if (File.separator.equals("String_Node_Str")) {
    currentDir=currentDir.replace('\\','/');
  }
  File dir=new File(currentDir);
  FileFilter filterForDirs=new FileFilter(){
    public boolean accept(    File file){
      return file.isDirectory();
    }
  }
;
  File[] children=dir.listFiles(filterForDirs);
  for (int i=0; i < children.length; i++) {
    proc(inputSuffix,outputFilename,root,children[i].toString());
  }
  FilenameFilter filterForOutputFilename=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.equals(outputFilename);
    }
  }
;
  ArrayList indexFiles=new ArrayList();
  for (int i=0; i < children.length; i++) {
    File[] grandchildren=children[i].listFiles(filterForOutputFilename);
    if (grandchildren.length == 1) {
      String indexFile=grandchildren[0].toString();
      String[] indexFileSubNames=indexFile.split("String_Node_Str");
      String newIndexFileName=indexFileSubNames[indexFileSubNames.length - 2] + "String_Node_Str" + indexFileSubNames[indexFileSubNames.length - 1];
      indexFiles.add(newIndexFileName);
    }
 else {
      if (grandchildren.length > 1) {
        throw new Exception("String_Node_Str" + outputFilename + "String_Node_Str"+ children[i]);
      }
    }
  }
  FilenameFilter filterForInputSuffix=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(inputSuffix) && !name.equals(outputFilename);
    }
  }
;
  String[] ncFiles=dir.list(filterForInputSuffix);
  String[] components={};
  if (ncFiles.length > 0) {
    components=new String[ncFiles.length];
    for (int i=0; i < ncFiles.length; i++) {
      String shortpath=currentDir.replaceFirst("String_Node_Str" + root,"String_Node_Str");
      shortpath=shortpath.replaceFirst("String_Node_Str" + "String_Node_Str","String_Node_Str");
      shortpath=shortpath + "String_Node_Str" + ncFiles[i];
      shortpath=shortpath.replaceFirst(inputSuffix + "String_Node_Str","String_Node_Str");
      components[i]=shortpath;
    }
  }
  String[] currentDirSubnames=null;
  try {
    currentDirSubnames=currentDir.split("String_Node_Str");
    if (currentDirSubnames.length < 1) {
      throw new Exception("String_Node_Str" + currentDir);
    }
  }
 catch (  java.util.regex.PatternSyntaxException ex) {
    throw new Exception("String_Node_Str" + currentDir + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",ex);
  }
  String libraryName=currentDirSubnames[currentDirSubnames.length - 1];
  String fullOutputFilename=currentDir + "String_Node_Str" + outputFilename;
  String[] stringArrayType={};
  MoMLLib.generateIndex(components,(String[])indexFiles.toArray(stringArrayType),libraryName,fullOutputFilename);
}

Fixed version (ground truth):
/** 
 * Traverse the directory tree recursively and generate .moml index files.
 * @param inputSuffix Suffix for the input files to look for.
 * @param outputFilename Name of the index file to generate.
 * @param root Root dir of the input files.
 * @param currentDir The current directory in this call to proc().
 * @exception Exception If internal error (duplicate file foundor invalid currentDir name.
 */
public static void proc(final String inputSuffix,final String outputFilename,String root,String currentDir) throws Exception {
  if (File.separator.equals("String_Node_Str")) {
    currentDir=currentDir.replace('\\','/');
  }
  File dir=new File(currentDir);
  FileFilter filterForDirs=new FileFilter(){
    public boolean accept(    File file){
      return file.isDirectory();
    }
  }
;
  File[] children=dir.listFiles(filterForDirs);
  for (int i=0; i < children.length; i++) {
    proc(inputSuffix,outputFilename,root,children[i].toString());
  }
  FilenameFilter filterForOutputFilename=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.equals(outputFilename);
    }
  }
;
  ArrayList indexFiles=new ArrayList();
  for (int i=0; i < children.length; i++) {
    File[] grandchildren=children[i].listFiles(filterForOutputFilename);
    if (grandchildren.length == 1) {
      String indexFile=grandchildren[0].toString();
      if (File.separator.equals("String_Node_Str")) {
        indexFile=indexFile.replace('\\','/');
      }
      String[] indexFileSubNames=indexFile.split("String_Node_Str");
      if (indexFileSubNames.length < 2) {
        throw new Exception("String_Node_Str");
      }
 else {
        String newIndexFileName=indexFileSubNames[indexFileSubNames.length - 2] + "String_Node_Str" + indexFileSubNames[indexFileSubNames.length - 1];
        indexFiles.add(newIndexFileName);
      }
    }
 else {
      if (grandchildren.length > 1) {
        throw new Exception("String_Node_Str" + outputFilename + "String_Node_Str"+ children[i]);
      }
    }
  }
  FilenameFilter filterForInputSuffix=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(inputSuffix) && !name.equals(outputFilename);
    }
  }
;
  String[] ncFiles=dir.list(filterForInputSuffix);
  String[] components={};
  if (ncFiles.length > 0) {
    components=new String[ncFiles.length];
    for (int i=0; i < ncFiles.length; i++) {
      String shortpath=currentDir.replaceFirst("String_Node_Str" + root,"String_Node_Str");
      shortpath=shortpath.replaceFirst("String_Node_Str" + "String_Node_Str","String_Node_Str");
      shortpath=shortpath + "String_Node_Str" + ncFiles[i];
      shortpath=shortpath.replaceFirst(inputSuffix + "String_Node_Str","String_Node_Str");
      components[i]=shortpath;
    }
  }
  String[] currentDirSubnames=null;
  try {
    currentDirSubnames=currentDir.split("String_Node_Str");
    if (currentDirSubnames.length < 1) {
      throw new Exception("String_Node_Str" + currentDir);
    }
  }
 catch (  java.util.regex.PatternSyntaxException ex) {
    throw new Exception("String_Node_Str" + currentDir + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",ex);
  }
  String libraryName=currentDirSubnames[currentDirSubnames.length - 1];
  String fullOutputFilename=currentDir + "String_Node_Str" + outputFilename;
  String[] stringArrayType={};
  MoMLLib.generateIndex(components,(String[])indexFiles.toArray(stringArrayType),libraryName,fullOutputFilename);
}