Skip to content

Commit b9cc60d

Browse files
Marc Knaupnlutsenko
Marc Knaup
authored andcommitted
Fixed crash when an NSBundle without executable is loaded (#981)
1 parent bf658db commit b9cc60d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m

+7-1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ - (void)_rawRegisterSubclass:(Class)kls {
340340

341341
- (void)_registerSubclassesInBundle:(NSBundle *)bundle {
342342
PFConsistencyAssert(bundle.loaded, @"Cannot register subclasses in a bundle that hasn't been loaded!");
343+
344+
const char *executablePath = bundle.executablePath.UTF8String;
345+
if (executablePath == NULL) {
346+
return;
347+
}
348+
343349
dispatch_sync(_registeredSubclassesAccessQueue, ^{
344350
Class pfObjectClass = [PFObject class];
345351

@@ -352,7 +358,7 @@ - (void)_registerSubclassesInBundle:(NSBundle *)bundle {
352358
// just use a simple array here.
353359
char potentialPaths[2][PATH_MAX] = { };
354360

355-
strncpy(potentialPaths[0], bundle.executablePath.UTF8String, PATH_MAX);
361+
strncpy(potentialPaths[0], executablePath, PATH_MAX);
356362
realpath(potentialPaths[0], potentialPaths[1]);
357363

358364
const char **classNames = NULL;

0 commit comments

Comments
 (0)