aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-01-29 15:56:11 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-29 21:16:44 +0000
commit926e193e5db4d98f10cda76a2b6a01b5c78753ad (patch)
tree8769861b41f9c77a0992cf2f8283bd3673efb4db
parenteb87d67a8300754b555f1408df67753649beecbc (diff)
check that rect is finite before jamming our bounds
Bug: skia:7507 Change-Id: I45ff36f96951f63795fdc09fdd8e3083865f6eda Reviewed-on: https://skia-review.googlesource.com/101461 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
-rw-r--r--src/core/SkPath.cpp2
-rw-r--r--tests/RectTest.cpp9
2 files changed, 10 insertions, 1 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index fe557d0fe9..ab8bf2e1fc 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -88,7 +88,7 @@ public:
~SkAutoPathBoundsUpdate() {
fPath->setConvexity(fDegenerate ? SkPath::kConvex_Convexity
: SkPath::kUnknown_Convexity);
- if (fEmpty || fHasValidBounds) {
+ if ((fEmpty || fHasValidBounds) && fRect.isFinite()) {
fPath->setBounds(fRect);
}
}
diff --git a/tests/RectTest.cpp b/tests/RectTest.cpp
index 6a588b7b6c..d34214d6d3 100644
--- a/tests/RectTest.cpp
+++ b/tests/RectTest.cpp
@@ -7,6 +7,7 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
+#include "SkPath.h"
#include "SkRect.h"
#include "SkRectPriv.h"
#include "Test.h"
@@ -95,6 +96,14 @@ DEF_TEST(Rect_grow, reporter) {
test_skbug4406(reporter);
}
+DEF_TEST(Rect_path_nan, reporter) {
+ SkRect r = { 0, 0, SK_ScalarNaN, 100 };
+ SkPath p;
+ p.addRect(r);
+ // path normally just jams its bounds to be r, but it must notice that r is non-finite
+ REPORTER_ASSERT(reporter, !p.isFinite());
+}
+
DEF_TEST(Rect_largest, reporter) {
REPORTER_ASSERT(reporter, !SkRectPriv::MakeILarge().isEmpty());
REPORTER_ASSERT(reporter, SkRectPriv::MakeILargestInverted().isEmpty());