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

Side by Side Diff: src/images/SkImageRef.cpp

Issue 116773002: Fixed more fuzzer issues (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Changed isAvailable for validateAvailable Created 7 years 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkImageRef.h" 8 #include "SkImageRef.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkFlattenableBuffers.h" 10 #include "SkFlattenableBuffers.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 /////////////////////////////////////////////////////////////////////////////// 160 ///////////////////////////////////////////////////////////////////////////////
161 161
162 SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) 162 SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex)
163 : INHERITED(buffer, mutex), fErrorInDecoding(false) { 163 : INHERITED(buffer, mutex), fErrorInDecoding(false) {
164 fSampleSize = buffer.readInt(); 164 fSampleSize = buffer.readInt();
165 fDoDither = buffer.readBool(); 165 fDoDither = buffer.readBool();
166 166
167 size_t length = buffer.getArrayCount(); 167 size_t length = buffer.getArrayCount();
168 fStream = SkNEW_ARGS(SkMemoryStream, (length)); 168 if (buffer.validateAvailable(length)) {
169 buffer.readByteArray((void*)fStream->getMemoryBase(), length); 169 fStream = SkNEW_ARGS(SkMemoryStream, (length));
170 buffer.readByteArray((void*)fStream->getMemoryBase(), length);
171 } else {
172 fStream = NULL;
173 }
170 174
171 fPrev = fNext = NULL; 175 fPrev = fNext = NULL;
172 fFactory = NULL; 176 fFactory = NULL;
173 } 177 }
174 178
175 void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const { 179 void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const {
176 this->INHERITED::flatten(buffer); 180 this->INHERITED::flatten(buffer);
177 181
178 buffer.writeInt(fSampleSize); 182 buffer.writeInt(fSampleSize);
179 buffer.writeBool(fDoDither); 183 buffer.writeBool(fDoDither);
180 // FIXME: Consider moving this logic should go into writeStream itself. 184 // FIXME: Consider moving this logic should go into writeStream itself.
181 // writeStream currently has no other callers, so this may be fine for 185 // writeStream currently has no other callers, so this may be fine for
182 // now. 186 // now.
183 if (!fStream->rewind()) { 187 if (!fStream->rewind()) {
184 SkDEBUGF(("Failed to rewind SkImageRef stream!")); 188 SkDEBUGF(("Failed to rewind SkImageRef stream!"));
185 buffer.write32(0); 189 buffer.write32(0);
186 } else { 190 } else {
187 // FIXME: Handle getLength properly here. Perhaps this class should 191 // FIXME: Handle getLength properly here. Perhaps this class should
188 // take an SkStreamAsset. 192 // take an SkStreamAsset.
189 buffer.writeStream(fStream, fStream->getLength()); 193 buffer.writeStream(fStream, fStream->getLength());
190 } 194 }
191 } 195 }
OLDNEW
« src/effects/SkDisplacementMapEffect.cpp ('K') | « src/effects/gradients/SkGradientShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698