diff --git a/sources/OpenMcdf/CompoundFile.cs b/sources/OpenMcdf/CompoundFile.cs index aadcc417..f706e118 100644 --- a/sources/OpenMcdf/CompoundFile.cs +++ b/sources/OpenMcdf/CompoundFile.cs @@ -1367,12 +1367,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."); + } } ///