From d9f7f99d919e5b91712e4457b452e0b4974e15a0 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 22 Oct 2019 18:05:03 -0700 Subject: [PATCH] Report error if font size value is zero or negative Summary: Text font size should not be negative, this diff throws an exception if TextView uses negative of zero font size Changelog: [[internal]] Reviewed By: shergin Differential Revision: D18068071 fbshipit-source-id: 4074dca2019b6223eef68a407570258adbceaa43 --- .../com/facebook/react/views/text/TextAttributeProps.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java index c6fc52b22c3..a0bf03f1413 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java @@ -204,6 +204,10 @@ public class TextAttributeProps { ? PixelUtil.toPixelFromSP(mLetterSpacingInput) : PixelUtil.toPixelFromDIP(mLetterSpacingInput); + if (mFontSize <= 0) { + throw new IllegalArgumentException( + "FontSize should be a positive value. Current value: " + mFontSize); + } // `letterSpacingPixels` and `mFontSize` are both in pixels, // yielding an accurate em value. return letterSpacingPixels / mFontSize;