Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Unified Diff: tests/DashPathEffectTest.cpp

Issue 2165013002: limit the number of points in SkDashPathEffect::asPoints (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fix SpecialLineRec point count overflow Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/utils/SkDashPath.cpp ('K') | « src/utils/SkDashPathPriv.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DashPathEffectTest.cpp
diff --git a/tests/DashPathEffectTest.cpp b/tests/DashPathEffectTest.cpp
index 7e832cdd6698ab5197f01270910733ad14e069a8..e3a380411dd726834f828533b362713ca8aceb59 100644
--- a/tests/DashPathEffectTest.cpp
+++ b/tests/DashPathEffectTest.cpp
@@ -10,6 +10,8 @@
#include "SkDashPathEffect.h"
#include "SkWriteBuffer.h"
#include "SkStrokeRec.h"
+#include "SkCanvas.h"
+#include "SkSurface.h"
// crbug.com/348821 was rooted in SkDashPathEffect refusing to flatten and unflatten itself when
// the effect is nonsense. Here we test that it fails when passed nonsense parameters.
@@ -99,3 +101,17 @@ DEF_TEST(DashPath_bug4871, r) {
SkPath fill;
paint.getFillPath(path, &fill);
}
+
+// Verify that long lines with many dashes don't cause overflows/OOMs.
+DEF_TEST(DashPathEffectTest_asPoints_limit, r) {
+ sk_sp<SkSurface> surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(256, 256)));
+ SkCanvas* canvas = surface->getCanvas();
+
+ SkPaint p;
+ p.setStyle(SkPaint::kStroke_Style);
+ // force the bounds to outset by a large amount
+ p.setStrokeWidth(5.0e10f);
+ const SkScalar intervals[] = { 1, 1 };
+ p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
+ canvas->drawLine(1, 1, 1, 5.0e10f, p);
+}
« src/utils/SkDashPath.cpp ('K') | « src/utils/SkDashPathPriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698