Skip to content

Commit

Permalink
Bundle check (#1119)
Browse files Browse the repository at this point in the history
* Check for NSBundle type before sending message

It seems the given `bundle` object may not be an NSBundle at times (appears to be capable of being at least an NSString), so we check to ensure the given parameter is of the expected type before we attempt to send a message with a potentially unkown selector.

* If we encounter an unloaded bundle, log it.
  • Loading branch information
levigroker authored and flovilmart committed Mar 31, 2017
1 parent d4974f1 commit e0e36ca
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ - (void)_rawRegisterSubclass:(Class)kls {

- (void)_registerSubclassesInLoadedBundle:(NSBundle *)bundle {
// Skip bundles that aren't loaded yet.
if (!bundle.loaded || !bundle.executablePath) {
if (![bundle isKindOfClass:NSBundle.class] || !bundle.loaded || !bundle.executablePath) {
return;
}
// Filter out any system bundles
Expand All @@ -343,7 +343,7 @@ - (void)_registerSubclassesInLoadedBundle:(NSBundle *)bundle {
}

- (void)_registerSubclassesInBundle:(NSBundle *)bundle {
PFConsistencyAssert(bundle.loaded, @"Cannot register subclasses in a bundle that hasn't been loaded!");
PFConsistencyAssert(bundle.loaded, @"Cannot register subclasses in an unloaded bundle: %@", bundle);

const char *executablePath = bundle.executablePath.UTF8String;
if (executablePath == NULL) {
Expand Down

0 comments on commit e0e36ca

Please sign in to comment.