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

Side by Side Diff: src/core/SkValidatingReadBuffer.cpp

Issue 2107453002: Fix Perlin noise fuzz issue (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Working Created 4 years, 5 months 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
« no previous file with comments | « no previous file | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkErrorInternals.h" 9 #include "SkErrorInternals.h"
10 #include "SkValidatingReadBuffer.h" 10 #include "SkValidatingReadBuffer.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 fFlattenableDict.set(fFlattenableDict.count() + 1, name); 241 fFlattenableDict.set(fFlattenableDict.count() + 1, name);
242 } else { 242 } else {
243 // Read the index. We are guaranteed that the first byte 243 // Read the index. We are guaranteed that the first byte
244 // is zeroed, so we must shift down a byte. 244 // is zeroed, so we must shift down a byte.
245 uint32_t index = fReader.readU32() >> 8; 245 uint32_t index = fReader.readU32() >> 8;
246 if (0 == index) { 246 if (0 == index) {
247 return nullptr; // writer failed to give us the flattenable 247 return nullptr; // writer failed to give us the flattenable
248 } 248 }
249 249
250 SkString* namePtr = fFlattenableDict.find(index); 250 SkString* namePtr = fFlattenableDict.find(index);
251 SkASSERT(namePtr); 251 if (!namePtr) {
252 return nullptr;
253 }
252 name = *namePtr; 254 name = *namePtr;
253 } 255 }
254 256
255 // Is this the type we wanted ? 257 // Is this the type we wanted ?
256 const char* cname = name.c_str(); 258 const char* cname = name.c_str();
257 SkFlattenable::Type baseType; 259 SkFlattenable::Type baseType;
258 if (!SkFlattenable::NameToType(cname, &baseType) || (baseType != type)) { 260 if (!SkFlattenable::NameToType(cname, &baseType) || (baseType != type)) {
259 return nullptr; 261 return nullptr;
260 } 262 }
261 263
(...skipping 12 matching lines...) Expand all
274 size_t offset = fReader.offset(); 276 size_t offset = fReader.offset();
275 obj = (*factory)(*this); 277 obj = (*factory)(*this);
276 // check that we read the amount we expected 278 // check that we read the amount we expected
277 size_t sizeRead = fReader.offset() - offset; 279 size_t sizeRead = fReader.offset() - offset;
278 this->validate(sizeRecorded == sizeRead); 280 this->validate(sizeRecorded == sizeRead);
279 if (fError) { 281 if (fError) {
280 obj = nullptr; 282 obj = nullptr;
281 } 283 }
282 return obj.release(); 284 return obj.release();
283 } 285 }
OLDNEW
« no previous file with comments | « no previous file | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698