diff options
author | Brian P. Hinz <bphinz@users.sf.net> | 2018-01-01 17:24:20 -0500 |
---|---|---|
committer | Brian P. Hinz <bphinz@users.sf.net> | 2018-01-16 23:28:37 -0500 |
commit | b40235af946e6854e7fcf1f8f7a00c165e71008e (patch) | |
tree | 8b1c795bb084e332349c02b2af13a61b9fb969fe /java/com/tigervnc/rdr/ZlibInStream.java | |
parent | 46fab93cbdc6f114f63279f0268ea3be94cd2922 (diff) | |
download | tigervnc-b40235af946e6854e7fcf1f8f7a00c165e71008e.tar.gz tigervnc-b40235af946e6854e7fcf1f8f7a00c165e71008e.zip |
Fixes for erros in java hextile/zrle decoders
Various errors exposed when connecting to RealVNC servers
on alternative platforms (ARM, SPARC). SSLEngineManager
was also cleaned up but most of the changes are cosmetic.
Diffstat (limited to 'java/com/tigervnc/rdr/ZlibInStream.java')
-rw-r--r-- | java/com/tigervnc/rdr/ZlibInStream.java | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/java/com/tigervnc/rdr/ZlibInStream.java b/java/com/tigervnc/rdr/ZlibInStream.java index 151633ec..12de0e8b 100644 --- a/java/com/tigervnc/rdr/ZlibInStream.java +++ b/java/com/tigervnc/rdr/ZlibInStream.java @@ -33,28 +33,12 @@ public class ZlibInStream extends InStream { bufSize = bufSize_; b = new byte[bufSize]; bytesIn = offset = 0; - zs = new ZStream(); - zs.next_in = null; - zs.next_in_index = 0; - zs.avail_in = 0; - if (zs.inflateInit() != JZlib.Z_OK) { - zs = null; - throw new Exception("ZlinInStream: inflateInit failed"); - } ptr = end = start = 0; + init(); } public ZlibInStream() { this(defaultBufSize); } - protected void finalize() throws Throwable { - try { - b = null; - zs.inflateEnd(); - } finally { - super.finalize(); - } - } - public void setUnderlying(InStream is, int bytesIn_) { underlying = is; @@ -62,6 +46,11 @@ public class ZlibInStream extends InStream { ptr = end = start; } + public int pos() + { + return offset + ptr - start; + } + public void removeUnderlying() { ptr = end = start; @@ -74,21 +63,32 @@ public class ZlibInStream extends InStream { underlying = null; } - public int pos() + public void reset() { - return offset + ptr - start; + deinit(); + init(); } - public void reset() + public void init() { - ptr = end = start; - if (underlying == null) return; + assert(zs == null); - while (bytesIn > 0) { - decompress(true); - end = start; // throw away any data + zs = new ZStream(); + zs.next_in = null; + zs.next_in_index = 0; + zs.avail_in = 0; + if (zs.inflateInit() != JZlib.Z_OK) { + zs = null; + throw new Exception("ZlinInStream: inflateInit failed"); } - underlying = null; + } + + public void deinit() + { + assert(zs != null); + removeUnderlying(); + zs.inflateEnd(); + zs = null; } protected int overrun(int itemSize, int nItems, boolean wait) |