From c25f356675de512f76168c93b85504062ca061bf Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 14 Jun 2017 05:20:47 -0700 Subject: [PATCH] Avoid crash when accessing jsContextRef without an executor Reviewed By: adamjernst Differential Revision: D5237039 fbshipit-source-id: 6a86da90605b896093e0ef99b0fcf079bf9854bf --- React/Base/RCTJavaScriptLoader.mm | 4 ++-- ReactCommon/cxxreact/Instance.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/React/Base/RCTJavaScriptLoader.mm b/React/Base/RCTJavaScriptLoader.mm index 29f6417ce..eb7c11e51 100755 --- a/React/Base/RCTJavaScriptLoader.mm +++ b/React/Base/RCTJavaScriptLoader.mm @@ -81,8 +81,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) code:RCTJavaScriptLoaderErrorNoScriptURL userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"No script URL provided. Make sure the packager is " - @"running or you have embedded a JS bundle in your application bundle." - @"unsanitizedScriptURLString:(%@)", unsanitizedScriptURLString]}]; + @"running or you have embedded a JS bundle in your application bundle.\n\n" + @"unsanitizedScriptURLString = %@", unsanitizedScriptURLString]}]; } return nil; } diff --git a/ReactCommon/cxxreact/Instance.cpp b/ReactCommon/cxxreact/Instance.cpp index ba8aef531..f7a55801a 100644 --- a/ReactCommon/cxxreact/Instance.cpp +++ b/ReactCommon/cxxreact/Instance.cpp @@ -115,7 +115,7 @@ void Instance::setGlobalVariable(std::string propName, } void *Instance::getJavaScriptContext() { - return nativeToJsBridge_->getJavaScriptContext(); + return nativeToJsBridge_ ? nativeToJsBridge_->getJavaScriptContext() : nullptr; } void Instance::callJSFunction(std::string&& module, std::string&& method, folly::dynamic&& params) {