#vulnerable code 
                             public int run(String[] args) throws Exception {

		final FileSystem fs = FileSystem.get(getConf());

		Options options = new Options();
		// automatically generate the help statement
		HelpFormatter formatter = new HelpFormatter();
		// create the parser
		CommandLineParser parser = new GnuParser();

		options.addOption("h", "help", false, "print this message");
		options.addOption("i", "input", true, "input file or directory");
		options.addOption("o", "output", true, "output Behemoth corpus");

		Path inputPath = null;
		Path outputPath = null;

		// parse the command line arguments
		CommandLine cmdLine = null;
		try {
			cmdLine = parser.parse(options, args);
			String input = cmdLine.getOptionValue("i");
			String output = cmdLine.getOptionValue("o");
			if (cmdLine.hasOption("help")) {
				formatter.printHelp("LanguageIdDriver", options);
				return 0;
			}
			if (input == null | output == null) {
				formatter.printHelp("LanguageIdDriver", options);
				return -1;
			}
			inputPath = new Path(input);
			outputPath = new Path(output);
		} catch (ParseException e) {
			formatter.printHelp("LanguageIdDriver", options);
		}
		
		// check whether needs overwriting
		if (fs.exists(outputPath)){
			  System.out.println("Output path "+outputPath + " already exists. Overwrite [y/n]?");
			  InputStreamReader inp = new InputStreamReader(System.in);
			  BufferedReader br = new BufferedReader(inp);
			  String str = br.readLine();
			  br.close();
			  if (str.equals("y")){
				  fs.delete(outputPath, true);
			  }
			  else return 0;
		}

		JobConf job = new JobConf(getConf());
		job.setJarByClass(this.getClass());

		job.setJobName("Processing with Language Identifier");

		job.setInputFormat(SequenceFileInputFormat.class);
		job.setOutputFormat(SequenceFileOutputFormat.class);

		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(BehemothDocument.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(BehemothDocument.class);

		job.setMapperClass(LanguageIdMapper.class);

		job.setNumReduceTasks(0);

		FileInputFormat.addInputPath(job, inputPath);
		FileOutputFormat.setOutputPath(job, outputPath);

		try {
			JobClient.runJob(job);
		} catch (Exception e) {
			e.printStackTrace();
			fs.delete(outputPath, true);
		} finally {
		}

		return 0;
	} 
                            #location 26 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             public int run(String[] args) throws Exception {

		final FileSystem fs = FileSystem.get(getConf());

		Options options = new Options();
		// automatically generate the help statement
		HelpFormatter formatter = new HelpFormatter();
		// create the parser
		CommandLineParser parser = new GnuParser();

		options.addOption("h", "help", false, "print this message");
		options.addOption("i", "input", true, "input file or directory");
		options.addOption("o", "output", true, "output Behemoth corpus");
		options.addOption("w", "overwrite", false, "overwrite the output");

		Path inputPath = null;
		Path outputPath = null;

		boolean overWrite = false;

		// parse the command line arguments
		CommandLine cmdLine = null;
		try {
			cmdLine = parser.parse(options, args);
			String input = cmdLine.getOptionValue("i");
			String output = cmdLine.getOptionValue("o");
			if (cmdLine.hasOption("help")) {
				formatter.printHelp("LanguageIdDriver", options);
				return 0;
			}
			if (input == null | output == null) {
				formatter.printHelp("LanguageIdDriver", options);
				return -1;
			}
			inputPath = new Path(input);
			outputPath = new Path(output);
			if (cmdLine.hasOption("overwrite")) {
				overWrite = true;
			}
		} catch (ParseException e) {
			formatter.printHelp("LanguageIdDriver", options);
		}

		// check whether needs overwriting
		if (fs.exists(outputPath)) {
			if (!overWrite) {
				System.out.println("Output path " + outputPath
						+ " already exists. Use option -w to overwrite.");
				return 0;
			} else
				fs.delete(outputPath, true);
		}

		JobConf job = new JobConf(getConf());
		job.setJarByClass(this.getClass());

		job.setJobName("Processing with Language Identifier");

		job.setInputFormat(SequenceFileInputFormat.class);
		job.setOutputFormat(SequenceFileOutputFormat.class);

		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(BehemothDocument.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(BehemothDocument.class);

		job.setMapperClass(LanguageIdMapper.class);

		// TODO make this optional based on presence of parameters
		job.setReducerClass(BehemothReducer.class);

		FileInputFormat.addInputPath(job, inputPath);
		FileOutputFormat.setOutputPath(job, outputPath);

		try {
			JobClient.runJob(job);
		} catch (Exception e) {
			e.printStackTrace();
			fs.delete(outputPath, true);
		} finally {
		}

		return 0;
	}