From 75e95544ed4abd4c36dfa6d69af0763e60d95a0a Mon Sep 17 00:00:00 2001 From: Marat Al Date: Tue, 17 Sep 2024 15:23:36 +0200 Subject: [PATCH] Fixed Xcode 16 arosed analyser warnings. --- Source/ARTDataEncoder.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/ARTDataEncoder.m b/Source/ARTDataEncoder.m index 4169f4ac4..140b9eb69 100644 --- a/Source/ARTDataEncoder.m +++ b/Source/ARTDataEncoder.m @@ -97,6 +97,9 @@ - (ARTDataEncoderOutput *)encode:(id)data { encoded = [data dataUsingEncoding:NSUTF8StringEncoding]; encoding = [NSString artAddEncoding:@"utf-8" toString:encoding]; } + if (encoded == nil) { + return [[ARTDataEncoderOutput alloc] initWithData:data encoding:nil errorInfo:[ARTErrorInfo createWithCode:0 message:@"must be NSString, NSData, NSArray or NSDictionary."]]; + } ARTStatus *status = [_cipher encrypt:encoded output:&toBase64]; if (status.state != ARTStateOk) { ARTErrorInfo *errorInfo = status.errorInfo ? status.errorInfo : [ARTErrorInfo createWithCode:0 message:@"encrypt failed"]; @@ -181,7 +184,7 @@ - (ARTDataEncoderOutput *)decode:(id)data identifier:(NSString *)identifier enco if (status.state != ARTStateOk) { errorInfo = status.errorInfo ? status.errorInfo : [ARTErrorInfo createWithCode:ARTErrorInvalidMessageDataOrEncoding message:@"decrypt failed"]; } - } else if ([encoding isEqualToString:@"vcdiff"] && _deltaCodec) { + } else if ([encoding isEqualToString:@"vcdiff"] && _deltaCodec && [data isKindOfClass:[NSData class]]) { NSError *decodeError; data = [_deltaCodec applyDelta:data deltaId:identifier baseId:_baseId error:&decodeError];