From b6b982f563f3ba8a310e7ea424519e528bdca830 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Fri, 10 Feb 2023 17:51:46 -0800 Subject: [PATCH] Add config null-check as remediation Summary: See code comment. D42282358 (https://github.com/facebook/react-native/commit/e55277c3310d8f6b712a57f80589cfe91ed35553) added usage of `YGConfigIsExperimentalFeatureEnabled` during layout, in a place where we sometimes encounter a Yoga node from RN which has an unexpectedly null config. This is a hack to stop the bleed while we add logging to figure out where the null config is coming from in RN. Changelog: [Internal] Reviewed By: rozele Differential Revision: D43203521 fbshipit-source-id: 2a21143a45c712ca00d16172f734fb116d165926 --- ReactCommon/yoga/yoga/Yoga.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 2c8f45b02d6270..bdbf51022dd100 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -4301,6 +4301,14 @@ YOGA_EXPORT void YGConfigSetExperimentalFeatureEnabled( YOGA_EXPORT bool YGConfigIsExperimentalFeatureEnabled( const YGConfigRef config, const YGExperimentalFeature feature) { + // S323291 + T145030974 + T145292944: Node config should never be null, but + // Yoga has a private API used by RN to set config which does not check, and + // we crash here where config is null. Add a null check as temporary + // remediation + if (config == nullptr) { + return false; + } + return config->experimentalFeatures[feature]; }