Index: src/core/SkImageInfo.cpp |
diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp |
index 461bdc030985fb632141a487b7d04b1fec8dba27..967b4f6f08cee6ccb91d4f6c6547d6871b205c04 100644 |
--- a/src/core/SkImageInfo.cpp |
+++ b/src/core/SkImageInfo.cpp |
@@ -8,6 +8,14 @@ |
#include "SkImageInfo.h" |
#include "SkFlattenableBuffers.h" |
+static bool alpha_type_is_valid(SkAlphaType alphaType) { |
+ return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); |
+} |
+ |
+static bool color_type_is_valid(SkColorType colorType) { |
+ return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); |
+} |
+ |
void SkImageInfo::unflatten(SkFlattenableReadBuffer& buffer) { |
fWidth = buffer.read32(); |
fHeight = buffer.read32(); |
@@ -16,6 +24,8 @@ void SkImageInfo::unflatten(SkFlattenableReadBuffer& buffer) { |
SkASSERT(0 == (packed >> 16)); |
fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); |
fColorType = (SkColorType)((packed >> 0) & 0xFF); |
+ buffer.validate(alpha_type_is_valid(fAlphaType) && |
+ color_type_is_valid(fColorType)); |
} |
void SkImageInfo::flatten(SkFlattenableWriteBuffer& buffer) const { |