mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Fix a crash when logging a JS exception that has no source file
Summary:
This error occurs primarily when starting the app and the packager is not running.
`source` can be null when the evaluated code does not come from a source file so it just crashes with a SIGSEGV when passing it to `String::adopt`. This restores the beloved 'Can't find variable __fbBatchedBridge' redbox error :)
Seems to be introduced in 17e1ceb543.
cc davidaurelio
Closes https://github.com/facebook/react-native/pull/5689
Reviewed By: svcscm
Differential Revision: D2890634
Pulled By: astreet
fb-gh-sync-id: b96bbe8e26c9ac580b1aa17222d2f59376832560
This commit is contained in:
committed by
facebook-github-bot-4
parent
6d65a90017
commit
2633f10588
@@ -56,7 +56,7 @@ JSValueRef evaluateScript(JSContextRef context, JSStringRef script, JSStringRef
|
||||
auto line = exception.asObject().getProperty("line");
|
||||
|
||||
std::ostringstream locationInfo;
|
||||
std::string file = String::adopt(source).str();
|
||||
std::string file = source != nullptr ? String::adopt(source).str() : "";
|
||||
locationInfo << "(" << (file.length() ? file : "<unknown file>");
|
||||
if (line != nullptr && line.isNumber()) {
|
||||
locationInfo << ":" << line.asInteger();
|
||||
|
||||
Reference in New Issue
Block a user