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

Unified Diff: src/core/SkImageFilter.cpp

Issue 83343003: Adding more validation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Attempting to upload yet again 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
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 9bf392515dbf0cc3e63942e9511e3035f568cfbc..437cac5d03a5883b8b1372fb9562ecd05e9d86db 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -53,20 +53,27 @@ SkImageFilter::~SkImageFilter() {
delete[] fInputs;
}
-SkImageFilter::SkImageFilter(SkFlattenableReadBuffer& buffer)
- : fInputCount(buffer.readInt()), fInputs(new SkImageFilter*[fInputCount]) {
- for (int i = 0; i < fInputCount; i++) {
- if (buffer.readBool()) {
- fInputs[i] = buffer.readImageFilter();
- } else {
- fInputs[i] = NULL;
+SkImageFilter::SkImageFilter(SkFlattenableReadBuffer& buffer, int maxInputCount) {
+ fInputCount = buffer.readInt();
+ if (buffer.validate((fInputCount >= 0) && (fInputCount <= maxInputCount))) {
+ fInputs = new SkImageFilter*[fInputCount];
+ for (int i = 0; i < fInputCount; i++) {
+ if (buffer.readBool()) {
+ fInputs[i] = buffer.readImageFilter();
+ } else {
+ fInputs[i] = NULL;
+ }
+ }
+ SkRect rect;
+ buffer.readRect(&rect);
+ if (buffer.validate(SkIsValidRect(rect))) {
+ uint32_t flags = buffer.readUInt();
+ fCropRect = CropRect(rect, flags);
}
+ } else {
+ fInputCount = 0;
+ fInputs = NULL;
}
- SkRect rect;
- buffer.readRect(&rect);
- uint32_t flags = buffer.readUInt();
- fCropRect = CropRect(rect, flags);
- buffer.validate(SkIsValidRect(rect));
}
void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {

Powered by Google App Engine
This is Rietveld 408576698