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

Unified Diff: src/core/SkBitmap.cpp

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Integrating readFoo changes Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 63a760c4cf7672a15068f8b801efc7a36d7d530e..13e72c119249c95cad0979c08f1ada59ae05f514 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -19,6 +19,7 @@
#include "SkThread.h"
#include "SkUnPreMultiply.h"
#include "SkUtils.h"
+#include "SkValidationUtils.h"
#include "SkPackBits.h"
#include <new>
@@ -1601,9 +1602,11 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
int width = buffer.readInt();
int height = buffer.readInt();
int rowBytes = buffer.readInt();
- int config = buffer.readInt();
+ Config config = (Config)buffer.readInt();
+ buffer.validate((width >= 0) && (height >= 0) && (rowBytes >= 0) &&
+ SkIsValidConfig(config));
- this->setConfig((Config)config, width, height, rowBytes);
+ this->setConfig(config, width, height, rowBytes);
this->setIsOpaque(buffer.readBool());
int reftype = buffer.readInt();
@@ -1617,6 +1620,7 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
case SERIALIZE_PIXELTYPE_NONE:
break;
default:
+ buffer.validate(false);
SkDEBUGFAIL("unrecognized pixeltype in serialized data");
sk_throw();
}

Powered by Google App Engine
This is Rietveld 408576698