diff --git a/React/Base/RCTJavaScriptLoader.m b/React/Base/RCTJavaScriptLoader.m index 8ea430702..c4341844f 100755 --- a/React/Base/RCTJavaScriptLoader.m +++ b/React/Base/RCTJavaScriptLoader.m @@ -42,16 +42,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) // Load local script file if (scriptURL.fileURL) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSError *error = nil; - NSData *source = nil; - // Load the first 4 bytes to check if the bundle is regular or RAM ("Random Access Modules" bundle). // The RAM bundle has a magic number in the 4 first bytes `(0xFB0BD1E5)`. // The benefit of RAM bundle over a regular bundle is that we can lazily inject // modules into JSC as they're required. FILE *bundle = fopen(scriptURL.path.UTF8String, "r"); if (!bundle) { - onComplete(RCTErrorWithMessage([NSString stringWithFormat:@"Error opening bundle %@", scriptURL.path]), source, 0); + onComplete(RCTErrorWithMessage([NSString stringWithFormat:@"Error opening bundle %@", scriptURL.path]), nil, 0); return; } @@ -59,12 +56,14 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) size_t readResult = fread(&magicNumber, sizeof(magicNumber), 1, bundle); fclose(bundle); if (readResult != 1) { - onComplete(RCTErrorWithMessage(@"Error reading bundle"), source, 0); + onComplete(RCTErrorWithMessage(@"Error reading bundle"), nil, 0); return; } magicNumber = NSSwapLittleIntToHost(magicNumber); + NSError *error = nil; + NSData *source = nil; int64_t sourceLength = 0; if (magicNumber == RCTRAMBundleMagicNumber) { source = [NSData dataWithBytes:&magicNumber length:sizeof(magicNumber)];