diff options
author | Brian Salomon <bsalomon@google.com> | 2017-11-20 21:56:29 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-27 14:17:26 +0000 |
commit | 4b0e364f92a91f935c4127a6ebe51a2557abb8ad (patch) | |
tree | a088887619b541bdc1caee6572d54eb027702845 | |
parent | f8fa50f0993a5dfb62b3cd59b8d95903ab8c3801 (diff) |
Disallow negative radii in deserialized SkRRects
bug= chromium:787124
Change-Id: I232ccd6bdfc2c176f97b97e24eabad6a9ce8e5e2
Reviewed-on: https://skia-review.googlesource.com/73901
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
-rw-r--r-- | src/core/SkRRect.cpp | 3 | ||||
-rw-r--r-- | tests/RoundRectTest.cpp | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp index 9b3d70e1fd..63fd8ccfcd 100644 --- a/src/core/SkRRect.cpp +++ b/src/core/SkRRect.cpp @@ -530,7 +530,8 @@ void SkRRect::dump(bool asHex) const { * We need all combinations of predicates to be true to have a "safe" radius value. */ static bool are_radius_check_predicates_valid(SkScalar rad, SkScalar min, SkScalar max) { - return (min <= max) && (rad <= max - min) && (min + rad <= max) && (max - rad >= min); + return (min <= max) && (rad <= max - min) && (min + rad <= max) && (max - rad >= min) && + rad >= 0; } bool SkRRect::isValid() const { diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp index 2e31cf1b65..43a51430ab 100644 --- a/tests/RoundRectTest.cpp +++ b/tests/RoundRectTest.cpp @@ -786,6 +786,8 @@ static void test_read(skiatest::Reporter* reporter) { test_read_rrect(reporter, rrect, false); *innerRadius = SK_ScalarNaN; test_read_rrect(reporter, rrect, false); + *innerRadius = -10.f; + test_read_rrect(reporter, rrect, false); } DEF_TEST(RoundRect, reporter) { |