mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
2a80579ea1
Summary: ManagedObjectWrapper (`wrapManagedObject`) is used to pass pointers managed by Objective-C runtime object thought C++ parts of the framework. The wrapper consists of a shared pointer to an object with a custom deleter that calls `CFRelease`. Apparently, there is a caveat here: shared ptr implementation always calls a deleter even if the object points to `nullptr`. It's usually fine because in C++ calling `delete` on a nullptr is a no-op, not an error. But it's an error from the `CFRelease` perspective, which checks the pointer and crashes if it's nullptr. More info: https://stackoverflow.com/questions/1135214/why-would-cfreleasenull-crash https://stackoverflow.com/questions/50201967/why-unique-ptr-with-custom-deleter-wont-work-for-nullptr-while-shared-ptr-does Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D21943011 fbshipit-source-id: 442ad5e274a146de112e6bd8f3c2d20f0225bf77