Fixed crash in TS parser - thx Verner :)

This commit is contained in:
niksedk 2015-09-13 20:27:52 +02:00
parent 2af71513f3
commit 798b46c927
2 changed files with 10 additions and 1 deletions

View File

@ -37,7 +37,7 @@ namespace Nikse.SubtitleEdit.Core.TransportStream
public DvbSubPes(byte[] buffer, int index)
{
if (buffer.Length < 9)
if (buffer.Length < index + 9)
return;
StartCode = Helper.GetEndian(buffer, index + 0, 3);
@ -59,6 +59,9 @@ namespace Nikse.SubtitleEdit.Core.TransportStream
HeaderDataLength = buffer[index + 8];
if (buffer.Length < index + 9 + HeaderDataLength)
return;
if (StreamId == 0xBD) // 10111101 binary = 189 decimal = 0xBD hex -> private_stream_1
{
int id = buffer[index + 9 + HeaderDataLength];

View File

@ -58,6 +58,12 @@ namespace Nikse.SubtitleEdit.Core.TransportStream
int dataType = buffer[index + 7];
int length = TopFieldDataBlockLength;
if (length + index + 7 > buffer.Length) // check if buffer is large enough
{
Image = new Bitmap(1, 1);
return;
}
index += 8;
int start = index;
int x = 0;