#vulnerable code 
                             public static void runExperiment(MultilabelClassifier h, String options[]) throws Exception {

		// Help
		if(Utils.getOptionPos('h',options) >= 0) {
			System.out.println("\nHelp requested");
			Evaluation.printOptions(h.listOptions());
			return;
		}

		h.setOptions(options);

		//Load Instances
		Instances allInstances = null;
		try {
			String filename = Utils.getOption('t', options);
			allInstances = new Instances(new BufferedReader(new FileReader(filename)));
		} catch(IOException e) {
			throw new Exception("[Error] Failed to Load Instances from file");
		}

		//Get the Options in the @relation name (in format 'dataset-name: <options>')
		String doptions[] = null;
		try {
			doptions = MLUtils.getDatasetOptions(allInstances);
		} catch(Exception e) {
			throw new Exception("[Error] Failed to Get Options from @Relation Name");
		}

		//Concatenate the Options in the @relation name to the cmd line options
		String full = "";
		for(String s : options) {
			if (s.length() > 0)
				full += (s + " ");
		}
		for(String s : doptions) {
			if (s.length() > 0)
				full += (s + " ");
		}
		options = Utils.splitOptions(full);

		//Set Options from the command line, any leftover options will most likely be used in the code that follows
		try {
			int c = (Utils.getOptionPos('C', options) >= 0) ? Integer.parseInt(Utils.getOption('C',options)) : Integer.parseInt(Utils.getOption('c',options));
			// if negative, then invert ...
			if ( c < 0) {
				c = -c;
				allInstances = MLUtils.switchAttributes(allInstances,c);
			}
			// end
			allInstances.setClassIndex(c);
		} catch(Exception e) {
			System.err.println("[Error] Failed to Set Options from Command Line -- Check\n\t the spelling of the base classifier;\n \t that options are specified in the correct order (respective to  the '--' divider); and\n\t that the class index is set properly.");
			System.exit(1);
		}

		//Check for the essential -C option. If still nothing set, we can't continue
		if(allInstances.classIndex() < 0) 
			throw new Exception("You must supply the number of labels either in the @Relation Name of the dataset or on the command line using the option: -C <num. labels>");

		//Set Range
		if(Utils.getOptionPos('p',options) >= 0) {

			// Randomize 
			if(Utils.getOptionPos('R',options) >= 0) {
				allInstances.randomize(new Random());
			}

			try {
				String range = Utils.getOption('p',options);
				System.out.println("Selecting Range "+range+"");
				RemoveRange remove = new RemoveRange();  
				remove.setInstancesIndices(range);
				remove.setInvertSelection(true);
				remove.setInputFormat(allInstances);
				allInstances = Filter.useFilter(allInstances, remove);
			} catch(Exception e) {
				System.out.println(""+e);
				e.printStackTrace();
				throw new Exception("Failed to Remove Range");
			}
		}

		int seed = (Utils.getOptionPos('s',options) >= 0) ? Integer.parseInt(Utils.getOption('s',options)) : 0;

		// Randomize (Instances)
		if(Utils.getOptionPos('R',options) >= 0) {
			allInstances.randomize(new Random(seed));
		}

		// Randomize (Method)
		if (h instanceof Randomizable) {
			((Randomizable)h).setSeed(seed + 1); // (@NOTE because previously we were using seed '1' as the default in BaggingML, we want to maintain reproducibility of older results with the same seed).
		}

		try {

			Result r = null;

			// Get Split
			if(Utils.getOptionPos('x',options) >= 0) {
				// CROSS-FOLD-VALIDATION
				int numFolds = MLUtils.getIntegerOption(Utils.getOption('x',options),10); // default 10
				r = new Result();
				Result fold[] = Evaluation.cvModel(h,allInstances,numFolds,(Utils.getOptionPos('T',options) >= 0) ? Utils.getOption('T',options) : "c");
				r.info = fold[0].info;
				for(String v : fold[0].vals.keySet()) {
					r.info.put(v,Result.getValues(v,fold));
				}
				HashMap<String,double[]> o = Result.getStats(fold);
				for(String s : o.keySet()) {
					double values[] = o.get(s);
					r.info.put(s,Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3));
				}
				r.setInfo("Type","CV");
				System.out.println(r.toString());
			}
			else {
				// TRAIN/TEST SPLIT
				int TRAIN = (int)(allInstances.numInstances() * 0.60), TEST;
				if(Utils.getOptionPos("split-percentage",options) >= 0) {
					double percentTrain = Double.parseDouble(Utils.getOption("split-percentage",options));
					TRAIN = (int)Math.round((allInstances.numInstances() * (percentTrain/100.0)));
				}
				else if(Utils.getOptionPos("split-number",options) >= 0) {
					TRAIN = Integer.parseInt(Utils.getOption("split-number",options));
				}

				TEST = allInstances.numInstances() - TRAIN;
				Instances train = new Instances(allInstances,0,TRAIN);
				train.setClassIndex(allInstances.classIndex());
				Instances test = new Instances(allInstances,TRAIN,TEST);
				test.setClassIndex(allInstances.classIndex());

				// Invert the split?
				if(Utils.getFlag('i',options)) { //boolean INVERT 			= Utils.getFlag('i',options);
					//Get Debug/Verbosity/Output Level

					Instances holder = test;
					test = train;
					train = holder;
				}

				// We're going to do parameter tuning
				if(Utils.getOptionPos('u',options) >= 0) {
					double percentageSplit = Double.parseDouble(Utils.getOption('u',options));
					TRAIN = (int)(train.numInstances() * percentageSplit);
					TEST = train.numInstances() - TRAIN;
					train = new Instances(train,0,TRAIN);
					test = new Instances(train,TRAIN,TEST);
				}

				if (h.getDebug()) System.out.println(":- Dataset -: "+MLUtils.getDatasetName(allInstances)+"\tL="+allInstances.classIndex()+"\tD(t:T)=("+train.numInstances()+":"+test.numInstances()+")\tLC(t:T)="+Utils.roundDouble(MLUtils.labelCardinality(train,allInstances.classIndex()),2)+":"+Utils.roundDouble(MLUtils.labelCardinality(test,allInstances.classIndex()),2)+")");

				r = evaluateModel(h,train,test,(Utils.getOptionPos('T',options) >= 0) ? Utils.getOption('T',options) : "c");
				r.output = Result.getStats(r);
				System.out.println(r.toString());

			}

			// Save ranking data?

			if (Utils.getOptionPos('f',options) >= 0) {
				Result.writeResultToFile(r,Utils.getOption('f',options));
			}

		} catch(Exception e) {
			e.printStackTrace();
			System.exit(1);
		}

		System.exit(0);
	} 
                            #location 16 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             public static void runExperiment(MultilabelClassifier h, String options[]) throws Exception {

		// Help
		if(Utils.getOptionPos('h',options) >= 0) {
			System.out.println("\nHelp requested");
			Evaluation.printOptions(h.listOptions());
			return;
		}

		h.setOptions(options);

		//Load Instances
		Instances allInstances = null;
		String filename = null;
		try {
			filename = Utils.getOption('t', options);
			allInstances = DataSource.read(filename);
		} catch(Exception e) {
			throw new Exception("[Error] Failed to Load Instances from file '" + filename + "'", e);
		}

		//Get the Options in the @relation name (in format 'dataset-name: <options>')
		String doptions[] = null;
		try {
			doptions = MLUtils.getDatasetOptions(allInstances);
		} catch(Exception e) {
			throw new Exception("[Error] Failed to Get Options from @Relation Name", e);
		}

		//Concatenate the Options in the @relation name to the cmd line options
		String full = "";
		for(String s : options) {
			if (s.length() > 0)
				full += (s + " ");
		}
		for(String s : doptions) {
			if (s.length() > 0)
				full += (s + " ");
		}
		options = Utils.splitOptions(full);

		//Set Options from the command line, any leftover options will most likely be used in the code that follows
		try {
			int c = (Utils.getOptionPos('C', options) >= 0) ? Integer.parseInt(Utils.getOption('C',options)) : Integer.parseInt(Utils.getOption('c',options));
			// if negative, then invert ...
			if ( c < 0) {
				c = -c;
				allInstances = MLUtils.switchAttributes(allInstances,c);
			}
			// end
			allInstances.setClassIndex(c);
		} catch(Exception e) {
			System.err.println("[Error] Failed to Set Options from Command Line -- Check\n\t the spelling of the base classifier;\n \t that options are specified in the correct order (respective to  the '--' divider); and\n\t that the class index is set properly.");
			System.exit(1);
		}

		//Check for the essential -C option. If still nothing set, we can't continue
		if(allInstances.classIndex() < 0) 
			throw new Exception("You must supply the number of labels either in the @Relation Name of the dataset or on the command line using the option: -C <num. labels>");

		//Set Range
		if(Utils.getOptionPos('p',options) >= 0) {

			// Randomize 
			if(Utils.getOptionPos('R',options) >= 0) {
				allInstances.randomize(new Random());
			}

			try {
				String range = Utils.getOption('p',options);
				System.out.println("Selecting Range "+range+"");
				RemoveRange remove = new RemoveRange();  
				remove.setInstancesIndices(range);
				remove.setInvertSelection(true);
				remove.setInputFormat(allInstances);
				allInstances = Filter.useFilter(allInstances, remove);
			} catch(Exception e) {
				System.out.println(""+e);
				e.printStackTrace();
				throw new Exception("Failed to Remove Range", e);
			}
		}

		int seed = (Utils.getOptionPos('s',options) >= 0) ? Integer.parseInt(Utils.getOption('s',options)) : 0;

		// Randomize (Instances)
		if(Utils.getOptionPos('R',options) >= 0) {
			allInstances.randomize(new Random(seed));
		}

		// Randomize (Method)
		if (h instanceof Randomizable) {
			((Randomizable)h).setSeed(seed + 1); // (@NOTE because previously we were using seed '1' as the default in BaggingML, we want to maintain reproducibility of older results with the same seed).
		}

		try {

			Result r = null;

			// Get Split
			if(Utils.getOptionPos('x',options) >= 0) {
				// CROSS-FOLD-VALIDATION
				int numFolds = MLUtils.getIntegerOption(Utils.getOption('x',options),10); // default 10
				r = new Result();
				Result fold[] = Evaluation.cvModel(h,allInstances,numFolds,(Utils.getOptionPos('T',options) >= 0) ? Utils.getOption('T',options) : "c");
				r.info = fold[0].info;
				for(String v : fold[0].vals.keySet()) {
					r.info.put(v,Result.getValues(v,fold));
				}
				HashMap<String,double[]> o = Result.getStats(fold);
				for(String s : o.keySet()) {
					double values[] = o.get(s);
					r.info.put(s,Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3));
				}
				r.setInfo("Type","CV");
				System.out.println(r.toString());
			}
			else {
				// TRAIN/TEST SPLIT
				int TRAIN = (int)(allInstances.numInstances() * 0.60), TEST;
				if(Utils.getOptionPos("split-percentage",options) >= 0) {
					double percentTrain = Double.parseDouble(Utils.getOption("split-percentage",options));
					TRAIN = (int)Math.round((allInstances.numInstances() * (percentTrain/100.0)));
				}
				else if(Utils.getOptionPos("split-number",options) >= 0) {
					TRAIN = Integer.parseInt(Utils.getOption("split-number",options));
				}

				TEST = allInstances.numInstances() - TRAIN;
				Instances train = new Instances(allInstances,0,TRAIN);
				train.setClassIndex(allInstances.classIndex());
				Instances test = new Instances(allInstances,TRAIN,TEST);
				test.setClassIndex(allInstances.classIndex());

				// Invert the split?
				if(Utils.getFlag('i',options)) { //boolean INVERT 			= Utils.getFlag('i',options);
					//Get Debug/Verbosity/Output Level

					Instances holder = test;
					test = train;
					train = holder;
				}

				// We're going to do parameter tuning
				if(Utils.getOptionPos('u',options) >= 0) {
					double percentageSplit = Double.parseDouble(Utils.getOption('u',options));
					TRAIN = (int)(train.numInstances() * percentageSplit);
					TEST = train.numInstances() - TRAIN;
					train = new Instances(train,0,TRAIN);
					test = new Instances(train,TRAIN,TEST);
				}

				if (h.getDebug()) System.out.println(":- Dataset -: "+MLUtils.getDatasetName(allInstances)+"\tL="+allInstances.classIndex()+"\tD(t:T)=("+train.numInstances()+":"+test.numInstances()+")\tLC(t:T)="+Utils.roundDouble(MLUtils.labelCardinality(train,allInstances.classIndex()),2)+":"+Utils.roundDouble(MLUtils.labelCardinality(test,allInstances.classIndex()),2)+")");

				r = evaluateModel(h,train,test,(Utils.getOptionPos('T',options) >= 0) ? Utils.getOption('T',options) : "c");
				r.output = Result.getStats(r);
				System.out.println(r.toString());

			}

			// Save ranking data?

			if (Utils.getOptionPos('f',options) >= 0) {
				Result.writeResultToFile(r,Utils.getOption('f',options));
			}

		} catch(Exception e) {
			e.printStackTrace();
			System.exit(1);
		}

		System.exit(0);
	}