Skip to content

Commit

Permalink
Catch NSException while unarchiving message text
Browse files Browse the repository at this point in the history
  • Loading branch information
tagavari committed Aug 11, 2022
1 parent 816b006 commit f0e837f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion AirMessage/Database/DatabaseConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,17 @@ class DatabaseConverter {
}

//Retrieve the archive contents
guard let attributedString = unarchiver.decodeObject() as? NSAttributedString else {
var decodedObject: Any?
do {
try ObjC.catchException {
decodedObject = unarchiver.decodeObject()
}
} catch {
LogManager.log("Encountered an exception while decoding object for message \(logID ?? "unknown"): \(error)", level: .notice)
return nil
}

guard let attributedString = decodedObject as? NSAttributedString else {
LogManager.log("Failed to decode object for message \(logID ?? "unknown")", level: .notice)
return nil
}
Expand Down

0 comments on commit f0e837f

Please sign in to comment.