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

Side by Side Diff: src/effects/SkMergeImageFilter.cpp

Issue 23548034: Follow up to serialization validation code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Merged in changes from 23021015 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkMergeImageFilter.h" 8 #include "SkMergeImageFilter.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (fModes) { 154 if (fModes) {
155 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); 155 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0]));
156 } 156 }
157 } 157 }
158 158
159 SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERI TED(buffer) { 159 SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERI TED(buffer) {
160 bool hasModes = buffer.readBool(); 160 bool hasModes = buffer.readBool();
161 if (hasModes) { 161 if (hasModes) {
162 this->initAllocModes(); 162 this->initAllocModes();
163 int nbInputs = countInputs(); 163 int nbInputs = countInputs();
164 SkASSERT(buffer.getArrayCount() == nbInputs * sizeof(fModes[0])); 164 bool sizeMatches = buffer.getArrayCount() == nbInputs * sizeof(fModes[0] );
165 buffer.validate(sizeMatches);
166 SkASSERT(sizeMatches);
165 buffer.readByteArray(fModes); 167 buffer.readByteArray(fModes);
166 for (int i = 0; i < nbInputs; ++i) { 168 for (int i = 0; i < nbInputs; ++i) {
167 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); 169 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i]));
168 } 170 }
169 } else { 171 } else {
170 fModes = 0; 172 fModes = 0;
171 } 173 }
172 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698