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

Unified Diff: src/effects/SkAlphaThresholdFilter.cpp

Issue 1713383002: fix misc asserts and checks found by fuzzer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « src/effects/Sk1DPathEffect.cpp ('k') | src/effects/SkDashPathEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkAlphaThresholdFilter.cpp
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index 79520602b719e69f169f7511415861e3d390f12f..406797084f7f8a4369f6087106572a41be817e5d 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -45,11 +45,19 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkAlphaThresholdFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkAlphaThresholdFilterImpl)
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
+static bool outside_unit(SkScalar x) {
+ return x < 0 || x > 1;
+}
SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
SkScalar innerThreshold,
SkScalar outerThreshold,
SkImageFilter* input) {
+ if (outside_unit(innerThreshold) || outside_unit(outerThreshold) ||
+ innerThreshold > outerThreshold)
+ {
+ return nullptr;
+ }
return new SkAlphaThresholdFilterImpl(region, innerThreshold, outerThreshold, input);
}
@@ -334,7 +342,6 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
bool SkAlphaThresholdFilterImpl::onFilterImageDeprecated(Proxy* proxy, const SkBitmap& src,
const Context& ctx, SkBitmap* dst,
SkIPoint* offset) const {
- SkASSERT(src.colorType() == kN32_SkColorType);
if (src.colorType() != kN32_SkColorType) {
return false;
« no previous file with comments | « src/effects/Sk1DPathEffect.cpp ('k') | src/effects/SkDashPathEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698