Skip to content

Commit 1ddb2bf

Browse files
committed
Check maxSize on finish
1 parent 20b8f26 commit 1ddb2bf

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
@@ -4048,14 +4048,20 @@ internal struct ValidatingInstantiateKeyPathBuffer: KeyPathPatternVisitor {
40484048
sizeVisitor.finish()
40494049
instantiateVisitor.finish()
40504050
isPureStruct.append(contentsOf: instantiateVisitor.isPureStruct)
4051-
checkSizeConsistency()
4051+
checkSizeConsistency(checkMaxSize: true)
40524052
}
40534053

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

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

0 commit comments

Comments
 (0)