Skip to content

demux_mkv: skip malformed TrackEntry elements - #18333

Open
acts-1631 wants to merge 1 commit into
mpv-player:masterfrom
acts-1631:limit-matroska-track-entries
Open

demux_mkv: skip malformed TrackEntry elements#18333
acts-1631 wants to merge 1 commit into
mpv-player:masterfrom
acts-1631:limit-matroska-track-entries

Conversation

@acts-1631

@acts-1631 acts-1631 commented Aug 1, 2026

Copy link
Copy Markdown

Malformed Matroska files can contain many TrackEntry elements without their
mandatory fields. The native demuxer creates persistent state for each entry
while opening the file, allowing unnecessary memory consumption.

Skip entries without TrackNumber, TrackUID, TrackType, or CodecID before
creating per-track state. Valid files with large track counts retain their
existing behavior.

@llyyr

llyyr commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Why is this a problem? There could be legitimate files with >256 tracks.

The Matroska demuxer creates persistent track state even if a TrackEntry
lacks mandatory fields. A malformed file can use a large list of such
entries to consume memory while it is opened.

Check TrackNumber, TrackUID, TrackType, and CodecID before creating
per-track state. Valid files with large track counts retain their
existing behavior.
@acts-1631
acts-1631 force-pushed the limit-matroska-track-entries branch from 5c68134 to 7d69d5d Compare August 2, 2026 22:22
@acts-1631 acts-1631 changed the title demux_mkv: limit Matroska TrackEntry count demux_mkv: skip malformed TrackEntry elements Aug 2, 2026
@acts-1631

Copy link
Copy Markdown
Author

Good point. I dropped the count cap. The revised patch skips only TrackEntry records missing mandatory fields before creating persistent track state, so valid files with large track counts retain their existing behavior.

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.

2 participants