RFR: 8294696 - BufferedInputStream.transferTo should drain buffer when mark set [v2]
Markus KARG
duke at openjdk.org
Sun Oct 23 08:46:46 UTC 2022
On Sun, 23 Oct 2022 06:21:02 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> It helps a bit but it still leaks the bytes in 0 to pos, and count buf.length. I think we have to assume that Dr. Evil's output stream will throw an exception so the code to replace the buffer won't run. This means replaces buf before handing out the original buffer. The transferTo method transfers all bytes to EOF so you may be able to get away with just allocating a 0 or tiny buffer, it can grow if needed with subsequent reads or transfers.
Silly me, you are certainly right! I have modified the code as you proposed, so now we should be safe, finally. :-)
-------------
PR: https://git.openjdk.org/jdk/pull/10525
More information about the core-libs-dev
mailing list