Program: 27852
Project: 27852
Buggy source:
/** 
 * Parses command-line arguments and runs the compiler.
 * @return system exit status
 */
protected int doRun() throws FlagUsageException, IOException {
  Compiler.setLoggingLevel(Level.parse(config.loggingLevel));
  List<SourceFile> externs=createExterns();
  compiler=createCompiler();
  B options=createOptions();
  List<JSModule> modules=null;
  Result result=null;
  setRunOptions(options);
  boolean writeOutputToFile=!config.jsOutputFile.isEmpty();
  List<String> outputFileNames=Lists.newArrayList();
  if (writeOutputToFile) {
    outputFileNames.add(config.jsOutputFile);
    jsOutput=fileNameToLegacyOutputWriter(config.jsOutputFile);
  }
 else   if (jsOutput instanceof OutputStream) {
    jsOutput=streamToLegacyOutputWriter((OutputStream)jsOutput);
  }
  List<String> jsFiles=config.js;
  List<String> moduleSpecs=config.module;
  boolean createCommonJsModules=false;
  if (options.processCommonJSModules) {
    if (moduleSpecs.size() == 1 && "String_Node_Str".equals(moduleSpecs.get(0))) {
      createCommonJsModules=true;
      moduleSpecs.remove(0);
    }
  }
  if (!moduleSpecs.isEmpty()) {
    modules=createJsModules(moduleSpecs,jsFiles);
    for (    JSModule m : modules) {
      outputFileNames.add(getModuleOutputFileName(m));
    }
    if (config.skipNormalOutputs) {
      compiler.initModules(externs,modules,options);
    }
 else {
      result=compiler.compileModules(externs,modules,options);
    }
  }
 else {
    List<SourceFile> inputs=createSourceInputs(jsFiles);
    if (config.skipNormalOutputs) {
      compiler.init(externs,inputs,options);
    }
 else {
      result=compiler.compile(externs,inputs,options);
    }
  }
  if (createCommonJsModules) {
    modules=Lists.newArrayList(compiler.getDegenerateModuleGraph().getAllModules());
    for (    JSModule m : modules) {
      outputFileNames.add(getModuleOutputFileName(m));
    }
  }
  for (  String outputFileName : outputFileNames) {
    if (compiler.getSourceFileByName(outputFileName) != null) {
      compiler.report(JSError.make(OUTPUT_SAME_AS_INPUT_ERROR,outputFileName));
      return 1;
    }
  }
  int errCode=processResults(result,modules,options);
  if (jsOutput instanceof Flushable) {
    ((Flushable)jsOutput).flush();
  }
  return errCode;
}

Fixed version (ground truth):
/** 
 * Parses command-line arguments and runs the compiler.
 * @return system exit status
 */
protected int doRun() throws FlagUsageException, IOException {
  Compiler.setLoggingLevel(Level.parse(config.loggingLevel));
  List<SourceFile> externs=createExterns();
  compiler=createCompiler();
  B options=createOptions();
  List<JSModule> modules=null;
  Result result=null;
  setRunOptions(options);
  boolean writeOutputToFile=!config.jsOutputFile.isEmpty();
  List<String> outputFileNames=Lists.newArrayList();
  if (writeOutputToFile) {
    outputFileNames.add(config.jsOutputFile);
  }
  List<String> jsFiles=config.js;
  List<String> moduleSpecs=config.module;
  boolean createCommonJsModules=false;
  if (options.processCommonJSModules) {
    if (moduleSpecs.size() == 1 && "String_Node_Str".equals(moduleSpecs.get(0))) {
      createCommonJsModules=true;
      moduleSpecs.remove(0);
    }
  }
  if (!moduleSpecs.isEmpty()) {
    modules=createJsModules(moduleSpecs,jsFiles);
    for (    JSModule m : modules) {
      outputFileNames.add(getModuleOutputFileName(m));
    }
    if (config.skipNormalOutputs) {
      compiler.initModules(externs,modules,options);
    }
 else {
      result=compiler.compileModules(externs,modules,options);
    }
  }
 else {
    List<SourceFile> inputs=createSourceInputs(jsFiles);
    if (config.skipNormalOutputs) {
      compiler.init(externs,inputs,options);
    }
 else {
      result=compiler.compile(externs,inputs,options);
    }
  }
  if (createCommonJsModules) {
    modules=Lists.newArrayList(compiler.getDegenerateModuleGraph().getAllModules());
    for (    JSModule m : modules) {
      outputFileNames.add(getModuleOutputFileName(m));
    }
  }
  for (  String outputFileName : outputFileNames) {
    if (compiler.getSourceFileByName(outputFileName) != null) {
      compiler.report(JSError.make(OUTPUT_SAME_AS_INPUT_ERROR,outputFileName));
      return 1;
    }
  }
  return processResults(result,modules,options);
}