#vulnerable code 
                              public static void main(String[] args) throws IOException, ParseException {

    if (args.length != 3) {
      System.err.println("Usage: SearcherCW09B <topicsFile> <submissionFile> <indexDir>");
      System.err.println("topicsFile: input file containing queries. One of: topics.web.1-50.txt topics.web.51-100.txt topics.web.101-150.txt topics.web.151-200.txt");
      System.err.println("submissionFile: redirect stdout to capture the submission file for trec_eval or gdeval.pl");
      System.err.println("indexDir: index directory");
      System.exit(1);
    }

    String topicsFile = args[0];
    String submissionFile = args[1];
    String indexDir = args[2];

    SearchClueWeb09b searcher = new SearchClueWeb09b(indexDir);
    searcher.search(topicsFile, submissionFile, QueryParser.Operator.OR);
    searcher.close();
  } 
                            #location 9 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              public static void main(String[] args) throws IOException, ParseException {

    long curTime = System.nanoTime();
    SearchArgs searchArgs = new SearchArgs();
    CmdLineParser parser = new CmdLineParser(searchArgs, ParserProperties.defaults().withUsageWidth(90));

    try {
      parser.parseArgument(args);
    } catch (CmdLineException e) {
      System.err.println(e.getMessage());
      parser.printUsage(System.err);
      System.err.println("Example: SearchGov2" + parser.printExample(OptionHandlerFilter.REQUIRED));
      return;
    }

    LOG.info("Reading index at " + searchArgs.index);
    Directory dir;
    if (searchArgs.inmem) {
      LOG.info("Using MMapDirectory with preload");
      dir = new MMapDirectory(Paths.get(searchArgs.index));
      ((MMapDirectory) dir).setPreload(true);
    } else {
      LOG.info("Using default FSDirectory");
      dir = FSDirectory.open(Paths.get(searchArgs.index));
    }

    Similarity similarity = null;

    if (searchArgs.ql) {
      LOG.info("Using QL scoring model");
      similarity = new LMDirichletSimilarity(searchArgs.mu);
    } else if (searchArgs.bm25) {
      LOG.info("Using BM25 scoring model");
      similarity = new BM25Similarity(searchArgs.k1, searchArgs.b);
    } else {
      LOG.error("Error: Must specify scoring model!");
      System.exit(-1);
    }

    RerankerCascade cascade = new RerankerCascade();
    if (searchArgs.rm3) {
      cascade.add(new Rm3Reranker(new EnglishAnalyzer(), "body", "src/main/resources/io/anserini/rerank/rm3/rm3-stoplist.gov2.txt"));
    } else {
      cascade.add(new IdentityReranker());
    }

    Path topicsFile = Paths.get(searchArgs.topics);

    if (!Files.exists(topicsFile) || !Files.isRegularFile(topicsFile) || !Files.isReadable(topicsFile)) {
      throw new IllegalArgumentException("Topics file : " + topicsFile + " does not exist or is not a (readable) file.");
    }

    SortedMap<Integer, String> topics = io.anserini.document.Collection.GOV2.equals(searchArgs.collection) ? readTeraByteTackQueries(topicsFile) : readWebTrackQueries(topicsFile);

    SearchClueWeb09b searcher = new SearchClueWeb09b(searchArgs.index);
    searcher.search(topics, searchArgs.output, similarity);
    searcher.close();
  }