Skip to content

Commit

Permalink
Merge pull request #132 from MichelZ/mize/improve_uniqueid
Browse files Browse the repository at this point in the history
Improve unique sector index validation
  • Loading branch information
ironfede authored Aug 3, 2024
2 parents 7926818 + ab465fa commit 2c60fa8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sources/OpenMcdf/CompoundFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,12 +1325,15 @@ int nextSecID

private void EnsureUniqueSectorIndex(int nextSecID, HashSet<int> processedSectors)
{
if (processedSectors.Contains(nextSecID) && this.validationExceptionEnabled)
if (!this.validationExceptionEnabled)
{
throw new CFCorruptedFileException("The file is corrupted.");
return;
}

processedSectors.Add(nextSecID);
if (!processedSectors.Add(nextSecID))
{
throw new CFCorruptedFileException("The file is corrupted.");
}
}

/// <summary>
Expand Down

0 comments on commit 2c60fa8

Please sign in to comment.