Skip to content

Commit

Permalink
Fabric: Fixed crash in colorComponentsFromColor()
Browse files Browse the repository at this point in the history
Summary:
This fixes a recently introduced crash in `colorComponentsFromColor()` (iOS implementation) caused by dereferencing a null pointer.

The fix is just a copy of a code fragment from a previous implementation.

Reviewed By: fkgozali

Differential Revision: D23944812

fbshipit-source-id: 977135dd75c4375affddfd75183e4890618ae819
  • Loading branch information
shergin authored and facebook-github-bot committed Sep 26, 2020
1 parent e2fd9d4 commit 920bd2c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ReactCommon/react/renderer/graphics/platform/ios/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ SharedColor colorFromComponents(ColorComponents components) {
}

ColorComponents colorComponentsFromColor(SharedColor sharedColor) {
if (!sharedColor) {
// Empty color object can be considered as `clear` (black, fully
// transparent) color.
return ColorComponents{0, 0, 0, 0};
}

float ratio = 256;
Color color = *sharedColor;
return ColorComponents{(float)((color >> 16) & 0xff) / ratio,
Expand Down

0 comments on commit 920bd2c

Please sign in to comment.