diff --git a/src/core/base_stream.js b/src/core/base_stream.js index bf252b24e..d26d9acd8 100644 --- a/src/core/base_stream.js +++ b/src/core/base_stream.js @@ -135,6 +135,10 @@ class BaseStream { unreachable("Abstract method `makeSubStream` called"); } + clone() { + unreachable("Abstract method `clone` called"); + } + /** * @returns {Array | null} */ diff --git a/src/core/decode_stream.js b/src/core/decode_stream.js index c8edbff22..619d6efc0 100644 --- a/src/core/decode_stream.js +++ b/src/core/decode_stream.js @@ -178,21 +178,16 @@ class DecodeStream extends BaseStream { return new Stream(this.buffer, start, length, dict); } - getBaseStreams() { - return this.stream ? this.stream.getBaseStreams() : null; - } - clone() { // Make sure it has been fully read. while (!this.eof) { this.readBlock(); } - return new Stream( - this.buffer, - this.start, - this.end - this.start, - this.dict.clone() - ); + return new Stream(this.buffer, 0, this.bufferLength, this.dict?.clone()); + } + + getBaseStreams() { + return this.stream ? this.stream.getBaseStreams() : null; } } diff --git a/src/core/stream.js b/src/core/stream.js index 41581f37f..ddb269772 100644 --- a/src/core/stream.js +++ b/src/core/stream.js @@ -88,8 +88,8 @@ class Stream extends BaseStream { return new Stream( this.bytes.buffer, this.start, - this.end - this.start, - this.dict.clone() + this.length, + this.dict?.clone() ); } }