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

Unified Diff: src/core/SkBitmap.cpp

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Adapting code to sk_once 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
« no previous file with comments | « include/effects/SkArithmeticMode.h ('k') | src/core/SkFlattenable.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 05f5208a69bfd62fba985d9f2e54e59d4853bb0d..046e20ab62b416f45f347efbbc14de833bcecccd 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>
@@ -268,7 +269,7 @@ void SkBitmap::getBounds(SkIRect* bounds) const {
///////////////////////////////////////////////////////////////////////////////
static bool validate_alphaType(SkBitmap::Config config, SkAlphaType alphaType,
- SkAlphaType* canonical) {
+ SkAlphaType* canonical = NULL) {
switch (config) {
case SkBitmap::kNo_Config:
alphaType = kIgnore_SkAlphaType;
@@ -1604,10 +1605,12 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
int width = buffer.readInt();
int height = buffer.readInt();
int rowBytes = buffer.readInt();
- int config = buffer.readInt();
- int alphaType = buffer.readInt();
+ Config config = (Config)buffer.readInt();
+ SkAlphaType alphaType = (SkAlphaType)buffer.readInt();
+ buffer.validate((width >= 0) && (height >= 0) && (rowBytes >= 0) &&
+ SkIsValidConfig(config) && validate_alphaType(config, alphaType));
- this->setConfig((Config)config, width, height, rowBytes, (SkAlphaType)alphaType);
+ this->setConfig(config, width, height, rowBytes, alphaType);
int reftype = buffer.readInt();
switch (reftype) {
@@ -1620,6 +1623,7 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
case SERIALIZE_PIXELTYPE_NONE:
break;
default:
+ buffer.validate(false);
SkDEBUGFAIL("unrecognized pixeltype in serialized data");
sk_throw();
}
« no previous file with comments | « include/effects/SkArithmeticMode.h ('k') | src/core/SkFlattenable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698