Chromium Code Reviews| Index: src/core/SkBitmap.cpp |
| diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp |
| index bad63bac18f5d25ba1445a06fbc2fef17f2ad68f..c2b24fdd92ca84952a199bd3b736505521fa44d2 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,13 @@ 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); |
| + this->setIsOpaque(buffer.readBool()); |
|
Stephen White
2013/10/21 21:22:37
Where is this bool written? I don't see it in flat
scroggo
2013/10/21 21:37:22
This line was deleted in a recent CL, and this one
sugoi1
2013/10/22 12:12:54
Good catch on the bad merge. Line deleted.
|
| int reftype = buffer.readInt(); |
| switch (reftype) { |
| @@ -1620,6 +1624,7 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) { |
| case SERIALIZE_PIXELTYPE_NONE: |
| break; |
| default: |
| + buffer.validate(false); |
| SkDEBUGFAIL("unrecognized pixeltype in serialized data"); |
| sk_throw(); |
| } |