From 62b7955406d62f68c0d89f2b2f838586084cdc2d Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Thu, 2 May 2024 17:17:57 -0400 Subject: [PATCH] Digital PCT265 defect CXTDT-552909 - Client crash prevention on invalid module JSON. --- MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index f2af3c3..4f90380 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -365,6 +365,16 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; - (void)addModulesToCache:(nonnull NSDictionary *)jsonDictionary queue:(nullable NSOperationQueue *)queue waitUntilFinished:(BOOL)waitUntilFinished completionBlock:(nullable void (^)(void))completionBlock { [jsonDictionary enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { + if (![obj isKindOfClass:[NSDictionary class]]) { + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] + initWithTitle:nil + messageToLog:[NSString stringWithFormat:@"Invalid module format. Cannot cache %@ as it's not an object", key] + code:ErrorCodeJSONNotDictionary + domain:ErrorDomainSystem + location:NSStringFromClass([self class])]; + [MVMCoreLoggingHandler.sharedLoggingHandler addErrorToLog:error]; + return; + } [self addModuleToCache:obj module:key]; }]; __weak typeof(self) weakSelf = self;