mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 20:52:44 +01:00
Try to prevent crash parsing mp4/bdsup
This commit is contained in:
parent
01c8abb025
commit
e5dda77f59
@ -4,7 +4,7 @@
|
||||
3.5.11 (xth October 2019) BETA
|
||||
* NEW:
|
||||
* Join: Can now append with "add time" - thx Michael/Nickola
|
||||
* Add format AWS JSON files - thx jaccoud
|
||||
* Add format AWS transcribe json - thx jaccoud
|
||||
* Add new subtitle format - thx Zhen
|
||||
* Add new subtitle format
|
||||
* Run only "Batch convert" in UI via "/batchconvert" - thx 07416
|
||||
|
@ -427,6 +427,14 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup
|
||||
|
||||
private static PcsData ParsePicture(byte[] buffer, SupSegment segment)
|
||||
{
|
||||
if (buffer.Length < 11)
|
||||
{
|
||||
return new PcsData
|
||||
{
|
||||
CompositionState = CompositionState.Invalid
|
||||
};
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var pcs = new PcsData
|
||||
{
|
||||
@ -435,7 +443,7 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup
|
||||
CompNum = BigEndianInt16(buffer, 5),
|
||||
CompositionState = GetCompositionState(buffer[7]),
|
||||
StartTime = segment.PtsTimestamp,
|
||||
PaletteUpdate = (buffer[8] == 0x80),
|
||||
PaletteUpdate = buffer[8] == 0x80,
|
||||
PaletteId = buffer[9]
|
||||
};
|
||||
// hi nibble: frame_rate, lo nibble: reserved
|
||||
@ -602,6 +610,8 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup
|
||||
var segment = fromMatroskaFile ? ParseSegmentHeaderFromMatroska(headerBuffer) : ParseSegmentHeader(headerBuffer, log);
|
||||
position += headerBuffer.Length;
|
||||
|
||||
try
|
||||
{
|
||||
// Read segment data
|
||||
var buffer = new byte[segment.Size];
|
||||
ms.Read(buffer, 0, buffer.Length);
|
||||
@ -752,10 +762,15 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup
|
||||
|
||||
default:
|
||||
#if DEBUG
|
||||
log.AppendLine($"0x?? - END offset={position} UNKOWN SEGMENT TYPE={segment.Type}");
|
||||
log.AppendLine($"0x?? - END offset={position} UNKNOWN SEGMENT TYPE={segment.Type}");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfRangeException e)
|
||||
{
|
||||
log.Append($"Index of of range at pos {position - headerBuffer.Length}: {e.StackTrace}");
|
||||
}
|
||||
position += segment.Size;
|
||||
segmentCount++;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes
|
||||
var textIndex = 0;
|
||||
while (index < allTimes.Count - 1)
|
||||
{
|
||||
if (index > 0 && SampleSizes[index + 1] == 2)
|
||||
if (index > 0 && index + 1 < SampleSizes.Count && SampleSizes[index + 1] == 2)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user