From 1dd161c833927d61d436fed68a80b07e44c65226 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Fri, 7 Apr 2017 10:46:39 -0400 Subject: Fix infinite loop in SkRTree::insert() When aspectRatio is not finite, insert() can fall into an infinite loop. This happens if you pass SkRect::MakeLargest() to the factory as bounds. BUG=skia:5974 Change-Id: Ibcc9e5c5943c718608d4c1448305f7b8f11413bc Reviewed-on: https://skia-review.googlesource.com/11784 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- tests/PictureBBHTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/PictureBBHTest.cpp') diff --git a/tests/PictureBBHTest.cpp b/tests/PictureBBHTest.cpp index 69cb443879..64b09b1e03 100644 --- a/tests/PictureBBHTest.cpp +++ b/tests/PictureBBHTest.cpp @@ -91,3 +91,15 @@ DEF_TEST(PictureBBH, reporter) { EmptyClipPictureBBHTest emptyClipPictureTest; emptyClipPictureTest.run(reporter); } + +DEF_TEST(RTreeMakeLargest, r) { + // A call to insert() with 2 or more rects and a bounds of SkRect::MakeLargest() + // used to fall into an infinite loop. + + SkRTreeFactory factory; + std::unique_ptr bbh{ factory(SkRect::MakeLargest()) }; + + SkRect rects[] = { {0,0, 10,10}, {5,5,15,15} }; + bbh->insert(rects, SK_ARRAY_COUNT(rects)); + REPORTER_ASSERT(r, bbh->getRootBound() == SkRect::MakeWH(15,15)); +} -- cgit v1.2.3