X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Futil%2Fio%2FLimitedInputStream.java;h=284d53dd25233bd8a9ea1dbbb2ec5fcc0065f2a5;hb=b905d1b51018f68ba5e8c598781a494921318c91;hp=8e23f24026454f32419248a4e6c792b9169c8375;hpb=87607d6d051b828515044b71a7ddb549e13deae1;p=jSite2.git diff --git a/src/net/pterodactylus/util/io/LimitedInputStream.java b/src/net/pterodactylus/util/io/LimitedInputStream.java index 8e23f24..284d53d 100644 --- a/src/net/pterodactylus/util/io/LimitedInputStream.java +++ b/src/net/pterodactylus/util/io/LimitedInputStream.java @@ -38,6 +38,9 @@ public class LimitedInputStream extends FilterInputStream { */ @Override public synchronized int available() throws IOException { + if (remaining == 0) { + return 0; + } return (int) Math.min(super.available(), Math.min(Integer.MAX_VALUE, remaining)); } @@ -73,7 +76,7 @@ public class LimitedInputStream extends FilterInputStream { */ @Override public synchronized long skip(long n) throws IOException { - if (n < 0) { + if ((n < 0) || (remaining == 0)) { return 0; } long skipped = super.skip(Math.min(n, remaining));