Skip to content

Commit c1c6bd7

Browse files
committed
Check maxSize on finish
1 parent e2aae59 commit c1c6bd7

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
@@ -4104,14 +4104,20 @@ internal struct ValidatingInstantiateKeyPathBuffer: KeyPathPatternVisitor {
41044104
sizeVisitor.finish()
41054105
instantiateVisitor.finish()
41064106
isPureStruct.append(contentsOf: instantiateVisitor.isPureStruct)
4107-
checkSizeConsistency()
4107+
checkSizeConsistency(checkMaxSize: true)
41084108
}
41094109

4110-
func checkSizeConsistency() {
4110+
func checkSizeConsistency(checkMaxSize: Bool = false) {
41114111
let nextDest = instantiateVisitor.destData.baseAddress._unsafelyUnwrappedUnchecked
41124112
let curSize = nextDest - origDest + MemoryLayout<Int>.size
41134113

4114-
_internalInvariant(curSize == sizeVisitor.sizeWithMaxSize,
4114+
let sizeVisitorSize = if checkMaxSize {
4115+
sizeVisitor.sizeWithMaxSize
4116+
} else {
4117+
sizeVisitor.size
4118+
}
4119+
4120+
_internalInvariant(curSize == sizeVisitorSize,
41154121
"size and instantiation visitors out of sync")
41164122
}
41174123
}

0 commit comments

Comments
 (0)