diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index eda206a9..410df8f4 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -26,7 +26,11 @@ NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; for (NSXMLNode *attribute in attributeEnum) { - dictionary[[attribute name]] = [attribute stringValue]; + NSString *attrName = [attribute name]; + if (!attrName) { + continue; + } + dictionary[attrName] = [attribute stringValue]; } return dictionary; } diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 1407d3fa..cde1ccd0 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -164,12 +164,15 @@ if (deltaDictionaries) { NSMutableDictionary *deltas = [NSMutableDictionary dictionary]; for (NSDictionary *deltaDictionary in deltaDictionaries) { + NSString *deltaFrom = deltaDictionary[SUAppcastAttributeDeltaFrom]; + if (!deltaFrom) continue; + NSMutableDictionary *fakeAppCastDict = [dict mutableCopy]; [fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas]; fakeAppCastDict[SURSSElementEnclosure] = deltaDictionary; SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict]; - deltas[deltaDictionary[SUAppcastAttributeDeltaFrom]] = deltaItem; + deltas[deltaFrom] = deltaItem; } self.deltaUpdates = deltas; } diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index a1b87634..5da386a1 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -169,17 +169,25 @@ typedef struct { return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory); } -- (NSString *)publicDSAKey +- (NSString *__nullable)publicDSAKey { // Maybe the key is just a string in the Info.plist. NSString *key = [self.bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey]; - if (key) { return key; } + if (key) { + return key; + } // More likely, we've got a reference to a Resources file by filename: NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey]; - if (!keyFilename) { return nil; } - NSError *ignoreErr = nil; - return [NSString stringWithContentsOfFile:[self.bundle pathForResource:keyFilename ofType:nil] encoding:NSASCIIStringEncoding error:&ignoreErr]; + if (!keyFilename) { + return nil; + } + + NSString *keyPath = [self.bundle pathForResource:keyFilename ofType:nil]; + if (!keyPath) { + return nil; + } + return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil]; } - (NSArray *)systemProfile diff --git a/Sparkle/SUPipedUnarchiver.m b/Sparkle/SUPipedUnarchiver.m index 7a65054c..7317143d 100644 --- a/Sparkle/SUPipedUnarchiver.m +++ b/Sparkle/SUPipedUnarchiver.m @@ -30,9 +30,13 @@ NSString *lastPathComponent = [path lastPathComponent]; for (NSString *currentType in typeSelectorDictionary) { + NSString *value = typeSelectorDictionary[currentType]; + assert(value); + if ([currentType length] > [lastPathComponent length]) continue; - if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType]) - return NSSelectorFromString(typeSelectorDictionary[currentType]); + if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType]) { + return NSSelectorFromString(value); + } } return NULL; } diff --git a/Sparkle/SUUpdatePermissionPrompt.m b/Sparkle/SUUpdatePermissionPrompt.m index 6aef7bd2..e9e47404 100644 --- a/Sparkle/SUUpdatePermissionPrompt.m +++ b/Sparkle/SUUpdatePermissionPrompt.m @@ -63,12 +63,16 @@ // If this is a background application we need to focus it in order to bring the prompt // to the user's attention. Otherwise the prompt would be hidden behind other applications and // the user would not know why the application was paused. - if ([aHost isBackgroundApplication]) { [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; } + if ([aHost isBackgroundApplication]) { + [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; + } - if( ![NSApp modalWindow]) // do not prompt if there is is another modal window on screen - { + if (![NSApp modalWindow]) { // do not prompt if there is is another modal window on screen SUUpdatePermissionPrompt *prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d]; - [NSApp runModalForWindow:[prompt window]]; + NSWindow *window = [prompt window]; + if (window) { + [NSApp runModalForWindow:window]; + } } }