summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiko Lehto <nikle@cendio.se>2020-02-03 09:57:56 +0100
committerNiko Lehto <nikle@cendio.se>2020-02-17 11:29:41 +0100
commitf6669ff7b2e489f0a55d2808ede674e64f777e7d (patch)
treee92b25b63408bd6f20fe76132f0378c88be31942
parentfe5aa6408aed83ec07e640cc9c0249688a7b710b (diff)
downloadnovnc-f6669ff7b2e489f0a55d2808ede674e64f777e7d.tar.gz
Move error handling to Inflate class
Every call wants this check so this should be done inside the class.
-rw-r--r--core/decoders/tight.js6
-rw-r--r--core/inflator.js4
2 files changed, 4 insertions, 6 deletions
diff --git a/core/decoders/tight.js b/core/decoders/tight.js
index 5a0a315..c226b33 100644
--- a/core/decoders/tight.js
+++ b/core/decoders/tight.js
@@ -161,9 +161,6 @@ export default class TightDecoder {
}
data = this._zlibs[streamId].inflate(data, uncompressedSize);
- if (data.length != uncompressedSize) {
- throw new Error("Incomplete zlib block");
- }
}
display.blitRgbImage(x, y, width, height, data, 0, false);
@@ -209,9 +206,6 @@ export default class TightDecoder {
}
data = this._zlibs[streamId].inflate(data, uncompressedSize);
- if (data.length != uncompressedSize) {
- throw new Error("Incomplete zlib block");
- }
}
// Convert indexed (palette based) image data to RGB
diff --git a/core/inflator.js b/core/inflator.js
index b7af040..726600f 100644
--- a/core/inflator.js
+++ b/core/inflator.js
@@ -37,6 +37,10 @@ export default class Inflate {
inflate(this.strm, 0); // Flush argument not used.
+ if (this.strm.next_out != expected) {
+ throw new Error("Incomplete zlib block");
+ }
+
return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
}