From 540f4c9638c293b400796635a4154e3996a2646b Mon Sep 17 00:00:00 2001 From: Ben Roth Date: Fri, 7 Apr 2017 10:47:17 -0700 Subject: [PATCH] Fix crash in `RCTRedBox::formatFrameSource:` Summary: Motivation: Similar to https://github.com/facebook/react-native/pull/13242 - the application will crash with `[NSNull lastPathComponent]: unrecognized selector sent to instance` if a stack frame with no filename makes it to RCTRedBox. Closes https://github.com/facebook/react-native/pull/13360 Differential Revision: D4848980 Pulled By: javache fbshipit-source-id: dc506f2ba39c2d4d68982b56a6e765a19dc048b0 --- React/Modules/RCTRedBox.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/React/Modules/RCTRedBox.m b/React/Modules/RCTRedBox.m index 7d7b47b49..c8003bc6d 100644 --- a/React/Modules/RCTRedBox.m +++ b/React/Modules/RCTRedBox.m @@ -185,8 +185,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (NSString *)formatFrameSource:(RCTJSStackFrame *)stackFrame { + NSString *fileName = RCTNilIfNull(stackFrame.file) ? [stackFrame.file lastPathComponent] : @""; NSString *lineInfo = [NSString stringWithFormat:@"%@:%zd", - [stackFrame.file lastPathComponent], + fileName, stackFrame.lineNumber]; if (stackFrame.column != 0) {