Index: src/effects/SkMatrixConvolutionImageFilter.cpp |
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp |
index c89b9dc63fce8711855b30e46e5b1222aaa68e8e..909facb0c973c2ff77df89dfcddb2a1aca269bf4 100644 |
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp |
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp |
@@ -20,6 +20,18 @@ |
#include "SkMatrix.h" |
#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, |
@@ -59,6 +71,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 { |