Skip to content

Commit bc7abac

Browse files
authored
Fix free with nil
1 parent dace09c commit bc7abac

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/PatternPreferences.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,14 @@ open class KVCPreferences: PreferencesAdapter {
492492
}
493493

494494
open func keys() -> [String] {
495-
var names: [String] = []
496495
var count: UInt32 = 0
497496
// FIXME: not recursive?
498-
let properties = class_copyPropertyList(self.object.classForCoder, &count)
497+
guard let properties = class_copyPropertyList(self.object.classForCoder, &count) else {
498+
return []
499+
}
500+
var names: [String] = []
499501
for i in 0 ..< Int(count) {
500-
let property: objc_property_t = properties![i]
502+
let property: objc_property_t = properties[i]
501503
let name: String = String(cString: property_getName(property))
502504
names.append(name)
503505
}

0 commit comments

Comments
 (0)