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

Unified Diff: src/core/SkImageFilter.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/core/SkBitmap.cpp ('k') | src/effects/SkBicubicImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 9bf392515dbf0cc3e63942e9511e3035f568cfbc..cca22bba5596eb7a99dc4762a3e63655f9d0a835 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(int maxInputCount, SkFlattenableReadBuffer& buffer) {
+ 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 {
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/effects/SkBicubicImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698