Index: src/effects/SkMatrixConvolutionImageFilter.cpp |
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp |
index d73f6335d74c7a1f13b8ee15985a7337041b68c1..90e4d91f2ed03c188f74e7c60cb3c48c7a60fcc8 100644 |
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp |
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp |
@@ -21,6 +21,18 @@ |
#endif |
+static bool tile_mode_is_valid(SkMatrixConvolutionImageFilter::TileMode tileMode) { |
+ switch (tileMode) { |
+ case SkMatrixConvolutionImageFilter::kClamp_TileMode: |
+ case SkMatrixConvolutionImageFilter::kRepeat_TileMode: |
+ case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode: |
+ return true; |
+ default: |
+ break; |
+ } |
+ return false; |
+} |
+ |
SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(const SkISize& kernelSize, const SkScalar* kernel, SkScalar gain, SkScalar bias, const SkIPoint& target, TileMode tileMode, bool convolveAlpha, SkImageFilter* input) |
: INHERITED(input), |
fKernelSize(kernelSize), |
@@ -50,6 +62,9 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkFlattenableRead |
fTarget.fY = buffer.readInt(); |
fTileMode = (TileMode) buffer.readInt(); |
fConvolveAlpha = buffer.readBool(); |
+ buffer.validate(SkScalarIsFinite(fGain) && |
+ SkScalarIsFinite(fBias) && |
+ tile_mode_is_valid(fTileMode)); |
} |
void SkMatrixConvolutionImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |