From 0881c8b68533ac0d70153b942a6a1ff8b0be275b Mon Sep 17 00:00:00 2001 From: Borewit Date: Thu, 18 Jul 2024 22:05:09 +0200 Subject: [PATCH] Prevent Matroska parser from crashing when the file size is unknown --- lib/matroska/MatroskaParser.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matroska/MatroskaParser.ts b/lib/matroska/MatroskaParser.ts index 923955eeb..4a88584ea 100644 --- a/lib/matroska/MatroskaParser.ts +++ b/lib/matroska/MatroskaParser.ts @@ -51,7 +51,8 @@ export class MatroskaParser extends BasicParser { } public async parse(): Promise { - const matroska = await this.parseContainer(matroskaDtd.elements, this.tokenizer.fileInfo.size, []) as any as IMatroskaDoc; + const containerSize = this.tokenizer.fileInfo.size ?? Number.MAX_SAFE_INTEGER; + const matroska = await this.parseContainer(matroskaDtd.elements, containerSize, []) as any as IMatroskaDoc; this.metadata.setFormat('container', `EBML/${matroska.ebml.docType}`); if (matroska.segment) {