Avoid crashes when signed prekey lookup fails.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-02-14 15:03:20 -05:00
parent 945c04f9e7
commit a132571087

View File

@ -142,8 +142,18 @@ const int kPreKeyOfLastResortId = 0xFFFFFF;
return -1;
}
ECKeyPair *ourSignedPrekey = [self.signedPreKeyStore loadSignedPrekey:message.signedPrekeyId].keyPair;
ECKeyPair *ourSignedPrekey = nil;
@try {
ourSignedPrekey = [self.signedPreKeyStore loadSignedPrekey:message.signedPrekeyId].keyPair;
} @catch (NSException *exception) {
NSLog(@"%@ %s Couldn't find signed prekey for id: %d, %@",
self.tag,
__PRETTY_FUNCTION__,
message.signedPrekeyId,
exception);
return -1;
}
ECKeyPair *_Nullable ourOneTimePreKey;
if (message.prekeyID >= 0) {
ourOneTimePreKey = [self.prekeyStore loadPreKey:message.prekeyID].keyPair;
@ -176,4 +186,16 @@ const int kPreKeyOfLastResortId = 0xFFFFFF;
}
}
#pragma mark - Logging
+ (NSString *)tag
{
return [NSString stringWithFormat:@"[%@]", self.class];
}
- (NSString *)tag
{
return self.class.tag;
}
@end