Merge branch 'master' into streamify
[nikiroo-utils.git] / src / be / nikiroo / utils / streams / BufferedInputStream.java
index af1e2ac932a4abb7d46815d34963dfcf8dbf6305..397f6fcf9b22f414631cddb899ab38a3b38f3fa1 100644 (file)
@@ -249,7 +249,7 @@ public class BufferedInputStream extends InputStream {
                while (hasMoreData() && done < blen) {
                        preRead();
                        if (hasMoreData()) {
-                               int now = Math.min(blen, stop) - start;
+                               int now = Math.min(blen - done, stop - start);
                                if (now > 0) {
                                        System.arraycopy(buffer, start, b, boff + done, now);
                                        start += now;