Skip to content

Commit 1a23902

Browse files
terriblebenide
authored andcommitted
Fix crash in RCTRedBox::formatFrameSource:
Summary: Motivation: Similar to #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 #13360 Differential Revision: D4848980 Pulled By: javache fbshipit-source-id: dc506f2ba39c2d4d68982b56a6e765a19dc048b0
1 parent 8c99cc4 commit 1a23902

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

React/Modules/RCTRedBox.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ - (void)copyStack
185185

186186
- (NSString *)formatFrameSource:(RCTJSStackFrame *)stackFrame
187187
{
188+
NSString *fileName = RCTNilIfNull(stackFrame.file) ? [stackFrame.file lastPathComponent] : @"<unknown file>";
188189
NSString *lineInfo = [NSString stringWithFormat:@"%@:%zd",
189-
[stackFrame.file lastPathComponent],
190+
fileName,
190191
stackFrame.lineNumber];
191192

192193
if (stackFrame.column != 0) {

0 commit comments

Comments
 (0)