Skip to content

Commit 08e1224

Browse files
authored
Merge pull request swiftlang#63302 from mikeash/keypath-big-32-bit-pointers
[Runtime] Fix key paths on 32-bit with KVC string pointers in the top half of memory.
2 parents 05a8aa4 + 1f8acac commit 08e1224

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stdlib/public/core/KeyPath.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ public class AnyKeyPath: Hashable, _AppendKeyPath {
177177
}
178178
else {
179179
let offset = Int(bitPattern: _kvcKeyPathStringPtr) - 1
180-
if (offset <= maximumOffsetOn32BitArchitecture) {
180+
// Pointers above 0x7fffffff will come in as negative numbers which are
181+
// less than maximumOffsetOn32BitArchitecture, be sure to reject them.
182+
if (offset >= 0 && offset <= maximumOffsetOn32BitArchitecture) {
181183
return offset
182184
}
183185
return nil

0 commit comments

Comments
 (0)