Skip to content

Commit 84997da

Browse files
committed
fix(sabr): clamp oversized webm elements so the vp9 segment index parses
1 parent c895c80 commit 84997da

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/sabr/SabrWebmSegmentIndexParser.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,13 @@ private static Element readElement(@Nonnull final byte[] data,
127127
final Varint size = readElementSize(data, offset + id.length, containerEnd);
128128
final int contentStart = offset + id.length + size.length;
129129
final int contentEnd;
130-
if (size.unknown) {
130+
if (size.unknown || size.value > Integer.MAX_VALUE
131+
|| contentStart + size.value > containerEnd) {
132+
// Segment (master) in a DASH/SABR init declares its full media size, way past the init
133+
// buffer we actually have. We only parse within the buffer (cues are found via the index
134+
// range), so clamp instead of failing. Without it itag 303 (vp9/webm) never gets a
135+
// segment index -> uniform-tiling fallback -> drift -> periodic video freeze.
131136
contentEnd = containerEnd;
132-
} else if (size.value > Integer.MAX_VALUE || contentStart + size.value > containerEnd) {
133-
throw new SabrProtocolException("Invalid WebM element size");
134137
} else {
135138
contentEnd = contentStart + (int) size.value;
136139
}

0 commit comments

Comments
 (0)