If we use a custom stream and specify limit on stream.read() length, WBMPImageReader.read() doesnt verify whether we are decoded complete data or not. We can check the length of data decoded and rerun the stream.read() or use readFully(). In case of other decoders like BMP we are using readFully(), so i have updated WBMPImageReader.read() to use readFully().
------------- Commit messages: - 8266435: WBMPImageReader.read() should not truncate the input stream Changes: https://git.openjdk.java.net/jdk/pull/6518/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6518&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8266435 Stats: 122 lines in 2 files changed: 118 ins; 0 del; 4 mod Patch: https://git.openjdk.java.net/jdk/pull/6518.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/6518/head:pull/6518 PR: https://git.openjdk.java.net/jdk/pull/6518