Skip to content

Commit

Permalink
Don't incur the penalty of validation if it's disabled. Also combin C…
Browse files Browse the repository at this point in the history
…ontains with Add
  • Loading branch information
MichelZ committed May 31, 2024
1 parent a61b6b9 commit ab465fa
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 @@ -1367,12 +1367,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 ab465fa

Please sign in to comment.