From f04d5e49e91832e122617fbbaa5cdb053459a7e7 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 28 Apr 2019 19:18:24 +0200 Subject: [PATCH] bufixes --- src/be/nikiroo/utils/Image.java | 4 +++- src/be/nikiroo/utils/streams/BufferedInputStream.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/be/nikiroo/utils/Image.java b/src/be/nikiroo/utils/Image.java index cfcaa74..ace43de 100644 --- a/src/be/nikiroo/utils/Image.java +++ b/src/be/nikiroo/utils/Image.java @@ -7,6 +7,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import be.nikiroo.utils.streams.MarkableFileInputStream; + /** * This class represents an image data. * @@ -91,7 +93,7 @@ public class Image implements Closeable { * in case of I/O error */ public InputStream newInputStream() throws IOException { - return new FileInputStream(data); + return new MarkableFileInputStream(new FileInputStream(data)); } /** diff --git a/src/be/nikiroo/utils/streams/BufferedInputStream.java b/src/be/nikiroo/utils/streams/BufferedInputStream.java index af1e2ac..397f6fc 100644 --- a/src/be/nikiroo/utils/streams/BufferedInputStream.java +++ b/src/be/nikiroo/utils/streams/BufferedInputStream.java @@ -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; -- 2.27.0