Skip to content

Commit 74ab40b

Browse files
authored
Merge pull request #63308 from mikeash/keypath-big-32-bit-pointers-5.8
[5.8][Runtime] Fix key paths on 32-bit with KVC string pointers in the top half of memory.
2 parents ae46805 + 1a44883 commit 74ab40b

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)