diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index 2119a8b108..153c6f4c48 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -90,6 +90,9 @@ sk_sp SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& bu if (!buffer.validate(kernelArea == count)) { return nullptr; } + if (!buffer.validateCanReadN(count)) { + return nullptr; + } SkAutoSTArray<16, SkScalar> kernel(count); if (!buffer.readScalarArray(kernel.get(), count)) { return nullptr; @@ -103,6 +106,9 @@ sk_sp SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& bu TileMode tileMode = buffer.read32LE(kLast_TileMode); bool convolveAlpha = buffer.readBool(); + if (!buffer.isValid()) { + return nullptr; + } return Make(kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode, convolveAlpha, common.getInput(0), &common.cropRect()); }