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

Unified Diff: src/effects/SkDisplacementMapEffect.cpp

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Adapting code to sk_once changes Created 7 years, 2 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/SkColorMatrixFilter.cpp ('k') | src/effects/SkDropShadowImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkDisplacementMapEffect.cpp
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index ff2e837d8aaea7eb41f4a447df6f9c6173151977..15ac62737214aeb4c48717526a6ca9ddd1adaa80 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -126,6 +126,20 @@ void computeDisplacement(SkDisplacementMapEffect::ChannelSelectorType xChannelSe
}
}
+bool channel_selector_type_is_valid(SkDisplacementMapEffect::ChannelSelectorType cst) {
+ switch (cst) {
+ case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
+ case SkDisplacementMapEffect::kR_ChannelSelectorType:
+ case SkDisplacementMapEffect::kG_ChannelSelectorType:
+ case SkDisplacementMapEffect::kB_ChannelSelectorType:
+ case SkDisplacementMapEffect::kA_ChannelSelectorType:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
} // end namespace
///////////////////////////////////////////////////////////////////////////////
@@ -152,6 +166,9 @@ SkDisplacementMapEffect::SkDisplacementMapEffect(SkFlattenableReadBuffer& buffer
fXChannelSelector = (SkDisplacementMapEffect::ChannelSelectorType) buffer.readInt();
fYChannelSelector = (SkDisplacementMapEffect::ChannelSelectorType) buffer.readInt();
fScale = buffer.readScalar();
+ buffer.validate(channel_selector_type_is_valid(fXChannelSelector) &&
+ channel_selector_type_is_valid(fYChannelSelector) &&
+ SkScalarIsFinite(fScale));
}
void SkDisplacementMapEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkDropShadowImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698