diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2016-09-15 15:49:04 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2016-09-15 15:50:16 +0800 |
commit | 2b22d3bfb4579971eccfaefa09ea077ce992e9d2 (patch) | |
tree | 640dacccd2aa598bd11f9b1df56d661328b9fb01 /platform | |
parent | c04373e6d50b20f7475049fbd5724b5ecd73fa30 (diff) | |
download | mupdf-2b22d3bfb4579971eccfaefa09ea077ce992e9d2.tar.xz |
JNI: Ensure that BufferInputStream position is in range.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/java/src/com/artifex/mupdf/fitz/BufferInputStream.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/platform/java/src/com/artifex/mupdf/fitz/BufferInputStream.java b/platform/java/src/com/artifex/mupdf/fitz/BufferInputStream.java index 6a03dc00..b1355612 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/BufferInputStream.java +++ b/platform/java/src/com/artifex/mupdf/fitz/BufferInputStream.java @@ -29,18 +29,23 @@ public class BufferInputStream extends InputStream } public int read() { - return buffer.readByte(position++); + int c = buffer.readByte(position); + if (c >= 0) + position++; + return c; } public int read(byte[] b) { int n = buffer.readBytes(position, b); - position += n; + if (n >= 0) + position += n; return n; } public int read(byte[] b, int off, int len) { int n = buffer.readBytesInto(position, b, off, len); - position += n; + if (n >= 0) + position += n; return n; } |