Fix other data endpoint issues

This commit is contained in:
Matt Nadareski
2023-11-15 12:44:32 -05:00
parent 58e538eff6
commit beca747943
2 changed files with 4 additions and 4 deletions

View File

@@ -48,9 +48,9 @@ namespace SabreTools.Serialization.Streams
break;
// Align to the 4-byte boundary if we're not at the end
if (data.Position != data.Length)
if (data.Position < data.Length)
{
while ((data.Position % 4) != 0)
while (data.Position < data.Length && (data.Position % 4) != 0)
_ = data.ReadByteValue();
}
else

View File

@@ -716,7 +716,7 @@ namespace SabreTools.Serialization.Streams
{
var attributeCertificateTable = new List<AttributeCertificateTableEntry>();
while (data.Position < endOffset && data.Position != data.Length)
while (data.Position < endOffset && data.Position < data.Length)
{
var entry = new AttributeCertificateTableEntry();
@@ -731,7 +731,7 @@ namespace SabreTools.Serialization.Streams
attributeCertificateTable.Add(entry);
// Align to the 8-byte boundary
while ((data.Position % 8) != 0 && data.Position < endOffset && data.Position != data.Length)
while ((data.Position % 8) != 0 && data.Position < endOffset && data.Position < data.Length)
_ = data.ReadByteValue();
}