Skip to content

Commit

Permalink
Move error handling to Inflate class
Browse files Browse the repository at this point in the history
Every call wants this check so this should be done inside the class.
  • Loading branch information
CendioNiko committed Feb 17, 2020
1 parent fe5aa64 commit f6669ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 0 additions & 6 deletions core/decoders/tight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions core/inflator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit f6669ff

Please sign in to comment.