diff options
author | Mike Reed <reed@google.com> | 2018-01-16 13:29:18 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-16 20:41:14 +0000 |
commit | 0ec7dc7a1bd5e9643c96c60b0d148c80c728fdae (patch) | |
tree | 5e5fed94f4edf6edcde033263e518fdd232f9aec /tests/RegionTest.cpp | |
parent | 42ee2845673c38f6d70f0d8ddf7e26dce8aa61d3 (diff) |
detect if the computed rgn bounds is too big
Bug:801869
Change-Id: I7380bfb86aedc719cf67e20e918ef39d1b143aee
Reviewed-on: https://skia-review.googlesource.com/95020
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'tests/RegionTest.cpp')
-rw-r--r-- | tests/RegionTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/RegionTest.cpp b/tests/RegionTest.cpp index 7fcf1014f7..be84d14c14 100644 --- a/tests/RegionTest.cpp +++ b/tests/RegionTest.cpp @@ -396,3 +396,26 @@ DEF_TEST(Region_readFromMemory_bad, r) { REPORTER_ASSERT(r, 0 == region.readFromMemory(data, sizeof(data))); } } + +DEF_TEST(region_toobig, reporter) { + const int big = 1 << 30; + const SkIRect neg = SkIRect::MakeXYWH(-big, -big, 10, 10); + const SkIRect pos = SkIRect::MakeXYWH( big, big, 10, 10); + + REPORTER_ASSERT(reporter, !neg.isEmpty()); + REPORTER_ASSERT(reporter, !pos.isEmpty()); + + SkRegion negR(neg); + SkRegion posR(pos); + + REPORTER_ASSERT(reporter, !negR.isEmpty()); + REPORTER_ASSERT(reporter, !posR.isEmpty()); + + SkRegion rgn; + rgn.op(negR, posR, SkRegion::kUnion_Op); + + // If we union those to rectangles, the resulting coordinates span more than int32_t, so + // we must mark the region as empty. + REPORTER_ASSERT(reporter, rgn.isEmpty()); +} + |