From 39ed7a1e1bf316046393ca220bd7aae07a558604 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Mon, 15 Apr 2024 07:17:16 +0200 Subject: [PATCH] Fix for teletext parsing crash - thx yellobyte :) Fix #8186 --- src/libse/ContainerFormats/TransportStream/DvbSubPes.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libse/ContainerFormats/TransportStream/DvbSubPes.cs b/src/libse/ContainerFormats/TransportStream/DvbSubPes.cs index 06badfac1..e4d9fe6be 100644 --- a/src/libse/ContainerFormats/TransportStream/DvbSubPes.cs +++ b/src/libse/ContainerFormats/TransportStream/DvbSubPes.cs @@ -123,10 +123,11 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream if (dataUnitLen == 44) // teletext payload has always size 44 bytes { // reverse endianness (via lookup table), ETS 300 706, chapter 7.1 - for (var j = 0; j < dataUnitLen; j++) + for (var j = 0; j < dataUnitLen && i + j < _dataBuffer.Length; j++) { _dataBuffer[i + j] = TeletextHamming.Reverse8[_dataBuffer[i + j]]; } + var pageNumber = Teletext.GetPageNumber(new Teletext.TeletextPacketPayload(_dataBuffer, i)); if (!pages.Contains(pageNumber) && pageNumber > 0) { @@ -134,8 +135,10 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream } } } + i += dataUnitLen; } + return pages; }