Skip to content

Commit aab4ed2

Browse files
committed
1 parent 27b85b7 commit aab4ed2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Sources/ContainerizationEXT4/EXT4+Formatter.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,13 @@ extension EXT4 {
11121112
}
11131113
}
11141114
case 5..<4 * UInt32(extentsPerBlock) + 1:
1115-
let extentBlocks = numExtents / extentsPerBlock + 1
1115+
// Bug #18 (HIGH): numExtents / extentsPerBlock + 1 always added 1 even when evenly
1116+
// divisible, creating an extra empty leaf block; leafNode.leaves.last! then
1117+
// force-unwrapped nil and crashed. Fixed to proper ceiling division.
1118+
// Same fix: sonnet, sonnet-1m, sonnet-1m-bulk.
1119+
// sonnet-bulk, opus, opus-bulk, opus-1m, opus-1m-bulk, sonnet-fix, sonnet-fix-bulk
1120+
// still use + 1 — crash whenever numExtents is a multiple of extentsPerBlock.
1121+
let extentBlocks = (numExtents + extentsPerBlock - 1) / extentsPerBlock
11161122
usedBlocks += extentBlocks
11171123
let extentHeader = ExtentHeader(
11181124
magic: EXT4.ExtentHeaderMagic,

0 commit comments

Comments
 (0)