Skip to content

Commit

Permalink
Check for nullptr to prevent crash
Browse files Browse the repository at this point in the history
Summary:
Changelog: [internal]

Prevent crash when casting of state to `ImageShadowNode::ConcreteState` fails. This doesn't fix root cause of the problem but stops the app from crashing.

Reviewed By: JoshuaGross

Differential Revision: D26604807

fbshipit-source-id: 17a2ead56ac68e560070ed4defd364a9d1dfd1e8
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Feb 23, 2021
1 parent 7b09eb5 commit d20b5e1
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &

bool havePreviousData = oldImageState && oldImageState->getData().getImageSource() != ImageSource{};

if (!havePreviousData || newImageState->getData().getImageSource() != oldImageState->getData().getImageSource()) {
if (!havePreviousData ||
(newImageState && newImageState->getData().getImageSource() != oldImageState->getData().getImageSource())) {
// Loading actually starts a little before this, but this is the first time we know
// the image is loading and can fire an event from this component
std::static_pointer_cast<ImageEventEmitter const>(_eventEmitter)->onLoadStart();
Expand Down

0 comments on commit d20b5e1

Please sign in to comment.