mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix crash when accessing nullptr imageRequest
Summary: ImageState if created with default constructor is created with `imageRequest_` being nullptr. Calling `getObserverCoordinator()` on it was causing a crash. We create initial state data with `imageRequest` populated. Changelog: [Internal] Reviewed By: shergin Differential Revision: D19332711 fbshipit-source-id: 0266222551dbfb10b3f86e72a43d5306650fd09b
This commit is contained in:
committed by
Facebook Github Bot
parent
16ada9dfb0
commit
cfbd93ccd5
@@ -20,6 +20,8 @@
|
||||
#import "RCTConversions.h"
|
||||
#import "RCTFabricComponentsPlugins.h"
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
@interface RCTImageComponentView () <RCTImageResponseDelegate>
|
||||
@end
|
||||
|
||||
@@ -79,8 +81,7 @@
|
||||
[super updateProps:props oldProps:oldProps];
|
||||
}
|
||||
|
||||
- (void)updateState:(facebook::react::State::Shared const &)state
|
||||
oldState:(facebook::react::State::Shared const &)oldState
|
||||
- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState
|
||||
{
|
||||
_state = std::static_pointer_cast<ImageShadowNode::ConcreteState const>(state);
|
||||
auto _oldState = std::static_pointer_cast<ImageShadowNode::ConcreteState const>(oldState);
|
||||
|
||||
@@ -35,6 +35,14 @@ class ImageShadowNode final : public ConcreteViewShadowNode<
|
||||
*/
|
||||
void setImageManager(const SharedImageManager &imageManager);
|
||||
|
||||
static ImageState initialStateData(
|
||||
ShadowNodeFragment const &fragment,
|
||||
SurfaceId const surfaceId,
|
||||
ComponentDescriptor const &componentDescriptor) {
|
||||
auto imageSource = ImageSource{ImageSource::Type::Invalid};
|
||||
return {imageSource, {imageSource, nullptr}};
|
||||
}
|
||||
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
void layout(LayoutContext layoutContext) override;
|
||||
|
||||
@@ -24,8 +24,6 @@ class ImageState final {
|
||||
imageRequest_(
|
||||
std::make_shared<ImageRequest>(std::move(imageRequest))){};
|
||||
|
||||
ImageState() = default;
|
||||
|
||||
/*
|
||||
* Returns stored ImageSource object.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user