#vulnerable code 
                                public void testWriteOutOfBounds() throws Exception {
        byte[] buf = new byte[1024];
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        Base64OutputStream out = new Base64OutputStream(bout);

        try {
            out.write(buf, -1, 0);
            fail("Expected Base64OutputStream.write(buf, -1, 0) to throw a IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException ioobe) {
            // Expected
        }

        try {
            out.write(buf, buf.length + 1, 0);
            fail("Expected Base64OutputStream.write(buf, buf.length + 1, 0) to throw a IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException ioobe) {
            // Expected
        }
    } 
                            #location 14 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public void testWriteOutOfBounds() throws Exception {
        byte[] buf = new byte[1024];
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        Base64OutputStream out = new Base64OutputStream(bout);

        try {
            out.write(buf, -1, 1);
            fail("Expected Base64OutputStream.write(buf, -1, 1) to throw a IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException ioobe) {
            // Expected
        }

        try {
            out.write(buf, 1, -1);
            fail("Expected Base64OutputStream.write(buf, 1, -1) to throw a IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException ioobe) {
            // Expected
        }

        try {
            out.write(buf, buf.length + 1, 0);
            fail("Expected Base64OutputStream.write(buf, buf.length + 1, 0) to throw a IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException ioobe) {
            // Expected
        }

        try {
            out.write(buf, buf.length - 1, 2);
            fail("Expected Base64OutputStream.write(buf, buf.length - 1, 2) to throw a IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException ioobe) {
            // Expected
        }        
    }