Fixing tracks array size with unknown/font tracks

This commit is contained in:
Zoe Roux 2022-04-17 13:17:35 +02:00
parent fcf56c205a
commit 341d20883d
No known key found for this signature in database
GPG Key ID: 54F19BB73170955D

View File

@ -142,16 +142,15 @@ namespace Kyoo.Core.Controllers
tracks = new Track[trackCount];
int j = 0;
for (int i = 0; i < arrayLength; i++)
for (int i = 0; i < arrayLength; i++, streamsPtr += size)
{
FTrack stream = Marshal.PtrToStructure<FTrack>(streamsPtr);
if (stream!.Type != FTrackType.Unknown && stream.Type != FTrackType.Attachment)
{
tracks[j] = stream.ToTrack();
j++;
}
streamsPtr += size;
if (stream!.Type == FTrackType.Unknown || stream.Type == FTrackType.Attachment)
continue;
tracks[j] = stream.ToTrack();
j++;
}
Array.Resize(ref tracks, j);
}
else
tracks = Array.Empty<Track>();
@ -207,11 +206,12 @@ namespace Kyoo.Core.Controllers
{
if (fastStop && _initialized)
return;
if (TranscoderAPI.Init() == Marshal.SizeOf<FTrack>())
return;
if (TranscoderAPI.Init() != Marshal.SizeOf<FTrack>())
{
_logger.LogCritical("The transcoder library could not be initialized correctly");
throw new HealthException("The transcoder library is corrupted or invalid.");
}
_initialized = true;
_logger.LogCritical("The transcoder library could not be initialized correctly");
throw new HealthException("The transcoder library is corrupted or invalid.");
}
/// <inheritdoc />