Skip to content

Treat zero-length WebM Channels as 0 instead of throwing a RangeError - #116

Open
Arda Zeybek (ardazeybek) wants to merge 1 commit into
microsoft:release/0.9.3from
ardazeybek:fix/webm-empty-channels
Open

Arda Zeybek (ardazeybek) wants to merge 1 commit into
microsoft:release/0.9.3from
ardazeybek:fix/webm-empty-channels

Conversation

@ardazeybek

Copy link
Copy Markdown

An audio track whose Channels element (0x9f) has a zero-byte payload made webmTracks call readUIntBE(start, 0), which throws a raw Node ERR_OUT_OF_RANGE ("The value of "byteLength" is out of range...") that was shown to the user. In EBML a zero-length unsigned integer means 0, so the file should hit the usual "Imported audio must be mono or stereo..." error instead.

The fix adds a small readUnsigned helper in electron/imports/tracks.ts that returns 0 for an empty element. This is the only variable-width integer read in the parser: the MP4 reads are fixed-width and the sample rate already checks its length (4 or 8 bytes).

Added a test in electron/imports/import.test.ts that fails before the change and passes after. npm run typecheck and npm test pass.

@ardazeybek

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant