From e0e36ca4595d1eac45600c9ebd66f8f06e548b90 Mon Sep 17 00:00:00 2001 From: Levi Brown Date: Fri, 31 Mar 2017 14:25:18 -0600 Subject: [PATCH] Bundle check (#1119) * 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. --- .../Object/Subclassing/PFObjectSubclassingController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m b/Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m index 0442f71af..1be108765 100644 --- a/Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m +++ b/Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m @@ -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 @@ -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) {