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

Unified Diff: src/core/SkBitmap.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 | « include/core/SkImageFilter.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 2fae75ae3841dd39d53c305ee83f70b8ae806fe5..429d09216a1328156d47d98a175383d79bf7452d 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -1622,19 +1622,21 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
this->setConfig(config, width, height, rowBytes, alphaType);
int reftype = buffer.readInt();
- switch (reftype) {
- case SERIALIZE_PIXELTYPE_REF_DATA: {
- size_t offset = buffer.readUInt();
- SkPixelRef* pr = buffer.readPixelRef();
- SkSafeUnref(this->setPixelRef(pr, offset));
- break;
+ if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) ||
+ (SERIALIZE_PIXELTYPE_NONE == reftype))) {
+ switch (reftype) {
+ case SERIALIZE_PIXELTYPE_REF_DATA: {
+ size_t offset = buffer.readUInt();
+ SkPixelRef* pr = buffer.readPixelRef();
+ SkSafeUnref(this->setPixelRef(pr, offset));
+ break;
+ }
+ case SERIALIZE_PIXELTYPE_NONE:
+ break;
+ default:
+ SkDEBUGFAIL("unrecognized pixeltype in serialized data");
+ sk_throw();
}
- case SERIALIZE_PIXELTYPE_NONE:
- break;
- default:
- buffer.validate(false);
- SkDEBUGFAIL("unrecognized pixeltype in serialized data");
- sk_throw();
}
}
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698