#vulnerable code 
                                public void loadVertices(int windowStart, int windowEnd, ChiVertex[] vertices)
            throws FileNotFoundException, IOException {
        if (adjData == null) {
            loadAdj();

            edataFilesize = (int) new File(edgeDataFilename).length();
            blockId = dataBlockManager.allocateBlock(edataFilesize);
        }


        System.out.println("Load memory shard");
        int vid = 0;
        int edataPtr = 0;
        int adjOffset = 0;
        int sizeOf = converter.sizeOf();
        DataInputStream adjInput = new DataInputStream(new ByteArrayInputStream(adjData));
        while(adjInput.available() > 0) {
            if (!hasSetOffset && vid > rangeEnd) {
                streamingOffset = adjOffset;
                streamingOffsetEdgePtr = edataPtr;
                streamingOffsetVid = vid;
                hasSetOffset = true;
            }
            if (!hasSetRangeOffset && vid >= rangeStart) {
                rangeStartOffset = adjOffset;
                rangeStartEdgePtr = edataPtr;
                hasSetRangeOffset = true;
            }

            int n = 0;
            int ns = adjInput.readUnsignedByte();
            adjOffset += 1;
            assert(ns >= 0);
            if (ns == 0) {
                // next value tells the number of vertices with zeros
                vid++;
                int nz = adjInput.readUnsignedByte();
                adjOffset += 1;
                vid += nz;
                continue;
            }
            if (ns == 0xff) {   // If 255 is not enough, then stores a 32-bit integer after.
                n = Integer.reverseBytes(adjInput.readInt());
                adjOffset += 4;
            } else {
                n = ns;
            }

            ChiVertex vertex = null;
            if (vid >= windowStart && vid <= windowEnd) {
                vertex = vertices[vid - windowStart];
            }

            while (--n >= 0) {
                int target = Integer.reverseBytes(adjInput.readInt());
                adjOffset += 4;
                if (!(target >= rangeStart && target <= rangeEnd))
                    throw new IllegalStateException("Target " + target + " not in range!");
                if (vertex != null) {
                    vertex.addOutEdge(blockId, edataPtr, target);
                }

                if (target >= windowStart) {
                    if (target <= windowEnd) {
                        ChiVertex dstVertex = vertices[target - windowStart];
                        if (dstVertex != null) {
                            dstVertex.addInEdge(blockId, edataPtr, vid);
                        }
                        if (vertex != null && dstVertex != null) {
                            dstVertex.parallelSafe = false;
                            vertex.parallelSafe = false;
                        }
                    }
                }
                edataPtr += sizeOf;

                // TODO: skip
            }
            vid++;
        }

        /* Load the edge data from file. Should be done asynchronously. */
        if (!loaded) {
            int read = 0;
            FileInputStream fdis = new FileInputStream(new File(edgeDataFilename));
            while (read < edataFilesize) {
                read += fdis.read(dataBlockManager.getRawBlock(blockId), read, edataFilesize - read);
            }

            loaded = true;
        }
    } 
                            #location 90 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             public void loadVertices(int windowStart, int windowEnd, ChiVertex[] vertices)
			throws FileNotFoundException, IOException {
		if (adjData == null) {
			blocksize = ChiFilenames.getBlocksize(converter.sizeOf());
			loadAdj();
			loadEdata();
		}

		System.out.println("Load memory shard");
		int vid = 0;
		int edataPtr = 0;
		int adjOffset = 0;
		int sizeOf = converter.sizeOf();
		DataInputStream adjInput = new DataInputStream(new ByteArrayInputStream(adjData));
		while(adjInput.available() > 0) {
			if (!hasSetOffset && vid > rangeEnd) {
				streamingOffset = adjOffset;
				streamingOffsetEdgePtr = edataPtr;
				streamingOffsetVid = vid;
				hasSetOffset = true;
			}
			if (!hasSetRangeOffset && vid >= rangeStart) {
				rangeStartOffset = adjOffset;
				rangeStartEdgePtr = edataPtr;
				hasSetRangeOffset = true;
			}

			int n = 0;
			int ns = adjInput.readUnsignedByte();
			adjOffset += 1;
			assert(ns >= 0);
			if (ns == 0) {
				// next value tells the number of vertices with zeros
				vid++;
				int nz = adjInput.readUnsignedByte();
				adjOffset += 1;
				vid += nz;
				continue;
			}
			if (ns == 0xff) {   // If 255 is not enough, then stores a 32-bit integer after.
				n = Integer.reverseBytes(adjInput.readInt());
				adjOffset += 4;
			} else {
				n = ns;
			}

			ChiVertex vertex = null;
			if (vid >= windowStart && vid <= windowEnd) {
				vertex = vertices[vid - windowStart];
			}

			while (--n >= 0) {
				int target = Integer.reverseBytes(adjInput.readInt());
				adjOffset += 4;
				if (!(target >= rangeStart && target <= rangeEnd))
					throw new IllegalStateException("Target " + target + " not in range!");
				if (vertex != null) {
					vertex.addOutEdge(blockIds[edataPtr / blocksize], edataPtr % blocksize, target);
				}

				if (target >= windowStart) {
					if (target <= windowEnd) {
						ChiVertex dstVertex = vertices[target - windowStart];
						if (dstVertex != null) {
							dstVertex.addInEdge(blockIds[edataPtr / blocksize], edataPtr % blocksize, vid);
						}
						if (vertex != null && dstVertex != null) {
							dstVertex.parallelSafe = false;
							vertex.parallelSafe = false;
						}
					}
				}
				edataPtr += sizeOf;

				// TODO: skip
			}
			vid++;
		}


	}