]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Move error handling to Inflate class
authorNiko Lehto <nikle@cendio.se>
Mon, 3 Feb 2020 08:57:56 +0000 (09:57 +0100)
committerNiko Lehto <nikle@cendio.se>
Mon, 17 Feb 2020 10:29:41 +0000 (11:29 +0100)
Every call wants this check so this should be done inside the class.

core/decoders/tight.js
core/inflator.js

index 5a0a315f82e0a39e707f96330b8f92227ed0d285..c226b33b09d06d994ae703cda334cc4c8c8c554e 100644 (file)
@@ -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
index b7af040f3d8f313066a782d8b3fc92e6067961c1..726600f98af710c89dad2ccab4529d9aee4ca324 100644 (file)
@@ -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);
     }