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

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

Issue 718103002: detect bad bitmaps during deserialization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: return true (but empty) if we just didn't recognize the codec type Created 6 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
« src/core/SkPictureData.cpp ('K') | « src/core/SkPictureData.cpp ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 8
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkErrorInternals.h" 10 #include "SkErrorInternals.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 SkBitmap subsetBm; 252 SkBitmap subsetBm;
253 SkIRect subset = SkIRect::MakeXYWH(xOffset, yOffset, width, heig ht); 253 SkIRect subset = SkIRect::MakeXYWH(xOffset, yOffset, width, heig ht);
254 if (bitmap->extractSubset(&subsetBm, subset)) { 254 if (bitmap->extractSubset(&subsetBm, subset)) {
255 bitmap->swap(subsetBm); 255 bitmap->swap(subsetBm);
256 return true; 256 return true;
257 } 257 }
258 } 258 }
259 // This bitmap was encoded when written, but we are unable to decode , possibly due to 259 // This bitmap was encoded when written, but we are unable to decode , possibly due to
260 // not having a decoder. 260 // not having a decoder.
261 SkErrorInternals::SetError(kParseError_SkError, 261 SkErrorInternals::SetError(kParseError_SkError,
262 "Could not decode bitmap. Resulting bitma p will be red."); 262 "Could not decode bitmap. Resulting bitma p will be red.");
scroggo 2014/11/12 18:24:48 I think this error message is well out of date.
reed1 2014/11/12 19:25:19 Yea, esp. the RED part. I will update.
263 // Even though we weren't able to decode the pixels, the readbuffer should still be
264 // intact, so we return true with an empty bitmap, so we don't for a n abort of the
scroggo 2014/11/12 18:24:48 force* ?
reed1 2014/11/12 19:25:19 Acknowledged.
265 // larger deserialize.
266 bitmap->setInfo(SkImageInfo::MakeUnknown(width, height));
267 return true;
263 } else { 268 } else {
264 // A size of zero means the SkBitmap was simply flattened. 269 // A size of zero means the SkBitmap was simply flattened.
265 if (this->isVersionLT(kNoMoreBitmapFlatten_Version)) { 270 if (this->isVersionLT(kNoMoreBitmapFlatten_Version)) {
266 SkBitmap tmp; 271 SkBitmap tmp;
267 tmp.legacyUnflatten(*this); 272 tmp.legacyUnflatten(*this);
268 // just throw this guy away 273 // just throw this guy away
scroggo 2014/11/12 18:24:48 This will fall through and return false. With the
reed1 2014/11/12 19:25:19 This is effectively dead code, which I will clean
269 } else { 274 } else {
270 if (SkBitmap::ReadRawPixels(this, bitmap)) { 275 if (SkBitmap::ReadRawPixels(this, bitmap)) {
271 return true; 276 return true;
272 } 277 }
273 } 278 }
274 } 279 }
275 } 280 }
276 // Could not read the SkBitmap. Use a placeholder bitmap. 281 // Could not read the SkBitmap. Use a placeholder bitmap.
277 bitmap->setInfo(SkImageInfo::MakeUnknown(width, height)); 282 bitmap->setInfo(SkImageInfo::MakeUnknown(width, height));
278 return false; 283 return false;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return; 360 return;
356 } 361 }
357 } else { 362 } else {
358 if (NULL == this->readFunctionPtr()) { 363 if (NULL == this->readFunctionPtr()) {
359 return; 364 return;
360 } 365 }
361 } 366 }
362 uint32_t sizeRecorded = fReader.readU32(); 367 uint32_t sizeRecorded = fReader.readU32();
363 fReader.skip(sizeRecorded); 368 fReader.skip(sizeRecorded);
364 } 369 }
OLDNEW
« src/core/SkPictureData.cpp ('K') | « src/core/SkPictureData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698