Skip to content

Commit

Permalink
Prevent Matroska parser from crashing when the file size is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Jul 18, 2024
1 parent 0587ce3 commit 966ffd6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/matroska/MatroskaParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class MatroskaParser extends BasicParser {
}

public async parse(): Promise<void> {
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) {
Expand Down

0 comments on commit 966ffd6

Please sign in to comment.