Skip to content

Commit efd2f67

Browse files
cipolleschimeta-codesync[bot]
authored andcommitted
Fix crash in RCTExceptionManager (#54550)
Summary: Pull Request resolved: #54550 # Summary This diff resolves a crash in RCTExceptionManager by modifying error handling. It fixes the issue by checking if `RCTJSExtraDataKey` and `RCTJSStackTraceKey` are null or not in a dictionary initializer. Also, `RCTJSExtraDataKey` is marked as nullable but its nullability is not checked. ## Changelog: [iOS][Fixed] - A Crash when some error information are nil Reviewed By: javache Differential Revision: D87140823 fbshipit-source-id: 896d41c5f6559206a6515e402d2a503df6ddb63c
1 parent 8b6b47b commit efd2f67

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/react-native/React/CoreModules/RCTExceptionsManager.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ - (void)reportFatal:(NSString *)message
7777
RCTTriggerReloadCommandListeners(@"JS Crash Reload");
7878
} else if (!RCT_DEV) {
7979
NSString *description = [@"Unhandled JS Exception: " stringByAppendingString:message];
80-
NSDictionary *errorInfo =
81-
@{NSLocalizedDescriptionKey : description, RCTJSStackTraceKey : stack, RCTJSExtraDataKey : extraDataAsJSON};
80+
NSDictionary *errorInfo = @{
81+
NSLocalizedDescriptionKey : description,
82+
RCTJSStackTraceKey : stack == nil ? (id)kCFNull : stack,
83+
RCTJSExtraDataKey : extraDataAsJSON == nil ? (id)kCFNull : extraDataAsJSON
84+
};
8285
RCTFatal([NSError errorWithDomain:RCTErrorDomain code:0 userInfo:errorInfo]);
8386
}
8487
}

0 commit comments

Comments
 (0)