From 4872075bf7841dc463cd8d41e6c27630b021af08 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 12 Apr 2016 07:55:04 +1000 Subject: [PATCH] #1762: Don't perform repetitive decompress. Pointed out by @sfPlayer1 --- native/src/main/java/net/md_5/bungee/jni/zlib/JavaZlib.java | 2 +- native/src/main/java/net/md_5/bungee/jni/zlib/NativeZlib.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/native/src/main/java/net/md_5/bungee/jni/zlib/JavaZlib.java b/native/src/main/java/net/md_5/bungee/jni/zlib/JavaZlib.java index 59810a5b..10da5d95 100644 --- a/native/src/main/java/net/md_5/bungee/jni/zlib/JavaZlib.java +++ b/native/src/main/java/net/md_5/bungee/jni/zlib/JavaZlib.java @@ -64,7 +64,7 @@ public class JavaZlib implements BungeeZlib { inflater.setInput( inData ); - while ( !inflater.finished() ) + while ( !inflater.finished() && inflater.getTotalIn() < inData.length ) { int count = inflater.inflate( buffer ); out.writeBytes( buffer, 0, count ); diff --git a/native/src/main/java/net/md_5/bungee/jni/zlib/NativeZlib.java b/native/src/main/java/net/md_5/bungee/jni/zlib/NativeZlib.java index 9b334b4f..f1f3b1e3 100644 --- a/native/src/main/java/net/md_5/bungee/jni/zlib/NativeZlib.java +++ b/native/src/main/java/net/md_5/bungee/jni/zlib/NativeZlib.java @@ -44,7 +44,7 @@ public class NativeZlib implements BungeeZlib out.memoryAddress(); Preconditions.checkState( ctx != 0, "Invalid pointer to compress!" ); - while ( !nativeCompress.finished ) + while ( !nativeCompress.finished && ( compress || in.isReadable() ) ) { out.ensureWritable( 8192 );