Skip to content

Commit 8266868

Browse files
committed
Check maxSize on finish
1 parent 91c7326 commit 8266868

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

stdlib/public/core/KeyPath.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4046,14 +4046,20 @@ internal struct ValidatingInstantiateKeyPathBuffer: KeyPathPatternVisitor {
40464046
sizeVisitor.finish()
40474047
instantiateVisitor.finish()
40484048
isPureStruct.append(contentsOf: instantiateVisitor.isPureStruct)
4049-
checkSizeConsistency()
4049+
checkSizeConsistency(checkMaxSize: true)
40504050
}
40514051

4052-
func checkSizeConsistency() {
4052+
func checkSizeConsistency(checkMaxSize: Bool = false) {
40534053
let nextDest = instantiateVisitor.destData.baseAddress._unsafelyUnwrappedUnchecked
40544054
let curSize = nextDest - origDest + MemoryLayout<Int>.size
40554055

4056-
_internalInvariant(curSize == sizeVisitor.sizeWithMaxSize,
4056+
let sizeVisitorSize = if checkMaxSize {
4057+
sizeVisitor.sizeWithMaxSize
4058+
} else {
4059+
sizeVisitor.size
4060+
}
4061+
4062+
_internalInvariant(curSize == sizeVisitorSize,
40574063
"size and instantiation visitors out of sync")
40584064
}
40594065
}

0 commit comments

Comments
 (0)