#vulnerable code 
                             public void execute() {
		
		if (control == null || !control.isDirectory()) {
			throw new BuildException("You need to point the 'control' attribute to the control directory.");
		}

		if (changesIn != null) {
			
			if (!changesIn.isFile() || !changesIn.canRead()) {
				throw new BuildException("The 'changesIn' attribute needs to point to a readable file. " + changesIn + " was not found/readable.");				
			}

			if (changesOut == null) {
				throw new BuildException("A 'changesIn' without a 'changesOut' does not make much sense.");
			}
			
			if (!isPossibleOutput(changesOut)) {
				throw new BuildException("Cannot write the output for 'changesOut' to " + changesOut);				
			}

			if (changesSave != null && !isPossibleOutput(changesSave)) {
				throw new BuildException("Cannot write the output for 'changesSave' to " + changesSave);				
			}
			
		} else {
			if (changesOut != null || changesSave != null) {
				throw new BuildException("The 'changesOut' or 'changesSave' attributes may only be used when there is a 'changesIn' specified.");							
			}
		}
				
		if (dataProducers.size() == 0) {
			throw new BuildException("You need to provide at least one reference to a tgz or directory with data.");
		}

		if (deb == null) {
			throw new BuildException("You need to point the 'destfile' attribute to where the deb is supposed to be created.");
		}
		
		final File[] controlFiles = control.listFiles();
		
		final DataProducer[] data = new DataProducer[dataProducers.size()];
		dataProducers.toArray(data);
		
		final Processor processor = new Processor(new Console() {
			public void println(String s) {
				if (verbose) {
					log(s);
				}
			}
		}, null);
		
		final PackageDescriptor packageDescriptor;
		try {

			packageDescriptor = processor.createDeb(controlFiles, data, deb);

			log("Created " + deb);

		} catch (Exception e) {
			throw new BuildException("Failed to create debian package " + deb, e);
		}

		final TextfileChangesProvider changesProvider;
		
		try {
			if (changesOut == null) {
				return;
			}

			// for now only support reading the changes form a textfile provider
			changesProvider = new TextfileChangesProvider(new FileInputStream(changesIn), packageDescriptor);
			
			processor.createChanges(packageDescriptor, changesProvider, (keyring!=null)?new FileInputStream(keyring):null, key, passphrase, new FileOutputStream(changesOut));

			log("Created changes file " + changesOut);
						
		} catch (Exception e) {
			throw new BuildException("Failed to create debian changes file " + changesOut, e);
		}

		try {
			if (changesSave == null) {
				return;
			}

			changesProvider.save(new FileOutputStream(changesSave));

			log("Saved changes to file " + changesSave);
			
		} catch (Exception e) {
			throw new BuildException("Failed to save debian changes file " + changesSave, e);
		}
				
	} 
                            #location 59 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             public void execute() {
		
		if (control == null || !control.isDirectory()) {
			throw new BuildException("You need to point the 'control' attribute to the control directory.");
		}

		if (changesIn != null) {
			
			if (!changesIn.isFile() || !changesIn.canRead()) {
				throw new BuildException("The 'changesIn' attribute needs to point to a readable file. " + changesIn + " was not found/readable.");				
			}

			if (changesOut == null) {
				throw new BuildException("A 'changesIn' without a 'changesOut' does not make much sense.");
			}
			
			if (!isPossibleOutput(changesOut)) {
				throw new BuildException("Cannot write the output for 'changesOut' to " + changesOut);				
			}

			if (changesSave != null && !isPossibleOutput(changesSave)) {
				throw new BuildException("Cannot write the output for 'changesSave' to " + changesSave);				
			}
			
		} else {
			if (changesOut != null || changesSave != null) {
				throw new BuildException("The 'changesOut' or 'changesSave' attributes may only be used when there is a 'changesIn' specified.");							
			}
		}
				
		if (dataProducers.size() == 0) {
			throw new BuildException("You need to provide at least one reference to a tgz or directory with data.");
		}

		if (deb == null) {
			throw new BuildException("You need to point the 'destfile' attribute to where the deb is supposed to be created.");
		}
		
		final File[] controlFiles = control.listFiles();
		
		final DataProducer[] data = new DataProducer[dataProducers.size()];
		dataProducers.toArray(data);
		
		final Processor processor = new Processor(new Console() {
			public void println(String s) {
				if (verbose) {
					log(s);
				}
			}
		}, null);
		
		final PackageDescriptor packageDescriptor;
		try {
			
			log("Creating debian package: " + deb);
			
			packageDescriptor = processor.createDeb(controlFiles, data, deb);

		} catch (Exception e) {
			throw new BuildException("Failed to create debian package " + deb, e);
		}

		final TextfileChangesProvider changesProvider;
		
		try {
			if (changesOut == null) {
				return;
			}

			log("Creating changes file: " + changesOut);

			// for now only support reading the changes form a textfile provider
			changesProvider = new TextfileChangesProvider(new FileInputStream(changesIn), packageDescriptor);
			
			processor.createChanges(packageDescriptor, changesProvider, (keyring!=null)?new FileInputStream(keyring):null, key, passphrase, new FileOutputStream(changesOut));
						
		} catch (Exception e) {
			throw new BuildException("Failed to create debian changes file " + changesOut, e);
		}

		try {
			if (changesSave == null) {
				return;
			}

			log("Saving changes to file: " + changesSave);

			changesProvider.save(new FileOutputStream(changesSave));
			
		} catch (Exception e) {
			throw new BuildException("Failed to save debian changes file " + changesSave, e);
		}
				
	}