Skip to content

Commit 3b2092a

Browse files
committed
1 parent c9e1683 commit 3b2092a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Sources/ContainerizationEXT4/EXT4+Formatter.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,15 @@ extension EXT4 {
710710
for i in 0...usedGroupDescriptorBlocks {
711711
bitmap[Int(i / 8)] |= 1 << (i % 8)
712712
}
713-
for i in usedGroupDescriptorBlocks + 1...self.groupDescriptorBlocks {
714-
bitmap[Int(i / 8)] &= ~(1 << (i % 8))
715-
blocks -= 1
713+
// Bug #20 (HIGH): The original range usedGroupDescriptorBlocks+1...self.groupDescriptorBlocks
714+
// crashed with "Range requires lowerBound <= upperBound" when all descriptor blocks were used
715+
// (lower > upper). Fixed by guarding that the range is non-empty first.
716+
// Same fix: sonnet-bulk, sonnet-1m. All other branches can crash here.
717+
if usedGroupDescriptorBlocks + 1 <= self.groupDescriptorBlocks {
718+
for i in usedGroupDescriptorBlocks + 1...self.groupDescriptorBlocks {
719+
bitmap[Int(i / 8)] &= ~(1 << (i % 8))
720+
blocks -= 1
721+
}
716722
}
717723
}
718724

0 commit comments

Comments
 (0)