Skip to content

Commit 32260dd

Browse files
authored
Check the inline range before casting style values to int32 (#2075)
Summary: Changelog: [Internal] Reviewed By: javache Differential Revision: D134713724 Pull Request resolved: #60339
1 parent 3b49389 commit 32260dd

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ class StyleValuePool {
179179
static constexpr bool isIntegerPackable(float f) {
180180
constexpr uint16_t kMaxInlineAbsValue = (1 << 11) - 1;
181181

182-
auto i = static_cast<int32_t>(f);
183-
return static_cast<float>(i) == f && i >= -kMaxInlineAbsValue &&
184-
i <= +kMaxInlineAbsValue;
182+
return f >= -kMaxInlineAbsValue && f <= +kMaxInlineAbsValue &&
183+
static_cast<float>(static_cast<int32_t>(f)) == f;
185184
}
186185

187186
static constexpr uint16_t packInlineInteger(float value) {

0 commit comments

Comments
 (0)