Check for nullability of [NSString UTF8String]

Summary:
Changelog: [internal]

[NSString UTF8String] is nullable. Therefore, we need to check if it isn't nil before passing it to std::string constructor which crashes if it's nil.

Reviewed By: shergin

Differential Revision: D23572652

fbshipit-source-id: 59e7f5e918b2e5c69333bfb687371f856555d8e0
This commit is contained in:
Samuel Susla
2020-09-08 10:27:17 -07:00
committed by Facebook GitHub Bot
parent 4d920fe7c9
commit 4b95bb2f84
+1 -1
View File
@@ -32,7 +32,7 @@ inline NSString *_Nullable RCTNSStringFromStringNilIfEmpty(
inline std::string RCTStringFromNSString(NSString *string)
{
return string ? std::string([string UTF8String]) : "";
return std::string{string.UTF8String ?: ""};
}
inline UIColor *_Nullable RCTUIColorFromSharedColor(const facebook::react::SharedColor &sharedColor)