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

Unified Diff: src/effects/SkMergeImageFilter.cpp

Issue 83343003: Adding more validation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed comments Created 7 years, 1 month 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/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMergeImageFilter.cpp
diff --git a/src/effects/SkMergeImageFilter.cpp b/src/effects/SkMergeImageFilter.cpp
index 93e23356101c71430716d530113f224b2abf9d0a..a755fe68cb768201643ba3ab7687d90360d76058 100755
--- a/src/effects/SkMergeImageFilter.cpp
+++ b/src/effects/SkMergeImageFilter.cpp
@@ -11,6 +11,9 @@
#include "SkFlattenableBuffers.h"
#include "SkValidationUtils.h"
+// Use 65535 as an arbitrary large number of inputs that this image filter should never overflow
+static const int kMaxInputs = 65535;
+
///////////////////////////////////////////////////////////////////////////////
void SkMergeImageFilter::initAllocModes() {
@@ -53,6 +56,7 @@ SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* first, SkImageFilter* seco
SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[],
const CropRect* cropRect) : INHERITED(count, filters, cropRect) {
+ SkASSERT(count <= kMaxInputs);
this->initModes(modes);
}
@@ -156,7 +160,8 @@ void SkMergeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
}
}
-SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
+SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer)
+ : INHERITED(kMaxInputs, buffer) {
bool hasModes = buffer.readBool();
if (hasModes) {
this->initAllocModes();
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698