#vulnerable code 
                             public long getAvailable() {
		long returnCurrentUsageMemory = 0;
		Scanner in = null;
		try {
			in = new Scanner(new FileReader("/proc/meminfo"));
		} catch (FileNotFoundException e) {
			return returnCurrentUsageMemory;
		}
		in.useDelimiter("\n");
		while (in.hasNext()) {
			String checkLine = in.next();
			if (checkLine.startsWith("MemAvailable:")) {
				String[] memorySplit = checkLine.split("\\s+");
				returnCurrentUsageMemory = parseMeminfo(memorySplit);
				break;
			} else if (checkLine.startsWith("MemFree:")) {
				String[] memorySplit = checkLine.split("\\s+");
				returnCurrentUsageMemory += parseMeminfo(memorySplit);
			} else if (checkLine.startsWith("Inactive:")) {
				String[] memorySplit = checkLine.split("\\s+");
				returnCurrentUsageMemory += parseMeminfo(memorySplit);
			}
		}
		in.close();
		return returnCurrentUsageMemory;
	} 
                            #location 24 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             public long getAvailable() {
		long availableMemory = 0;
		List<String> memInfo = null;
		try {
			memInfo = FileUtil.readFile("/proc/meminfo");
		} catch (IOException e) {
			System.err.println("Problem with: /proc/meminfo");
			System.err.println(e.getMessage());
			return availableMemory;
		}
		for (String checkLine : memInfo) {
			// If we have MemAvailable, it trumps all. See code in
			// https://git.kernel.org/cgit/linux/kernel/git/torvalds/
			// linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
			if (checkLine.startsWith("MemAvailable:")) {
				String[] memorySplit = checkLine.split("\\s+");
				availableMemory = parseMeminfo(memorySplit);
				break;
			} else
			// Otherwise we combine MemFree + Active(file), Inactive(file), and
			// SReclaimable. Free+cached is no longer appropriate. MemAvailable
			// reduces these values using watermarks to estimate when swapping
			// is prevented, omitted here for simplicity (assuming 0 swap).
			if (checkLine.startsWith("MemFree:")) {
				String[] memorySplit = checkLine.split("\\s+");
				availableMemory += parseMeminfo(memorySplit);
			} else if (checkLine.startsWith("Active(file):")) {
				String[] memorySplit = checkLine.split("\\s+");
				availableMemory += parseMeminfo(memorySplit);
			} else if (checkLine.startsWith("Inactive(file):")) {
				String[] memorySplit = checkLine.split("\\s+");
				availableMemory += parseMeminfo(memorySplit);
			} else if (checkLine.startsWith("SReclaimable:")) {
				String[] memorySplit = checkLine.split("\\s+");
				availableMemory += parseMeminfo(memorySplit);
			}
		}
		return availableMemory;
	}