diff --git a/sources/OpenMcdf/CompoundFile.cs b/sources/OpenMcdf/CompoundFile.cs index ae0a2fee..df2d429d 100644 --- a/sources/OpenMcdf/CompoundFile.cs +++ b/sources/OpenMcdf/CompoundFile.cs @@ -1325,12 +1325,15 @@ int nextSecID private void EnsureUniqueSectorIndex(int nextSecID, HashSet 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."); + } } ///