Skip to content

Commit 70dfdc8

Browse files
committed
add some type checking
1 parent ee20a7d commit 70dfdc8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Foundation/NSKeyedArchiver.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ internal let NSKeyedArchivePlistVersion = 100000
2020
internal let NSKeyedArchiverSystemVersion : UInt32 = 2000
2121

2222
internal func objectRefGetValue(objectRef : CFKeyedArchiverUID) -> UInt32 {
23+
if objectRef.dynamicType != __NSCFType.self ||
24+
CFGetTypeID(objectRef) != _CFKeyedArchiverUIDGetTypeID() {
25+
fatalError("Object \(objectRef) is not a CFKeyedArchiverUID")
26+
}
2327
return _CFKeyedArchiverUIDGetValue(unsafeBitCast(objectRef, CFKeyedArchiverUIDRef.self))
2428
}
2529
internal var NSPropertyListClasses : [AnyClass] = [

Foundation/NSKeyedUnarchiver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public class NSKeyedUnarchiver : NSCoder {
355355
Returns true if objectOrReference represents a reference to another object in the archive
356356
*/
357357
internal class func _isReference(objectOrReference : Any?) -> Bool {
358-
if let cf = objectOrReference as? AnyObject {
358+
if let cf = objectOrReference as? __NSCFType {
359359
return CFGetTypeID(cf) == _CFKeyedArchiverUIDGetTypeID()
360360
} else {
361361
return false

0 commit comments

Comments
 (0)