Index: src/images/SkImageRef.cpp |
diff --git a/src/images/SkImageRef.cpp b/src/images/SkImageRef.cpp |
index 716519f080d0ab8e2f9d2dc964b73eb80224406b..843f4c01f941d3aa9b962d785ba095122397bae0 100644 |
--- a/src/images/SkImageRef.cpp |
+++ b/src/images/SkImageRef.cpp |
@@ -165,8 +165,12 @@ SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) |
fDoDither = buffer.readBool(); |
size_t length = buffer.getArrayCount(); |
- fStream = SkNEW_ARGS(SkMemoryStream, (length)); |
- buffer.readByteArray((void*)fStream->getMemoryBase(), length); |
+ if (buffer.validateAvailable(length)) { |
+ fStream = SkNEW_ARGS(SkMemoryStream, (length)); |
+ buffer.readByteArray((void*)fStream->getMemoryBase(), length); |
+ } else { |
+ fStream = NULL; |
+ } |
fPrev = fNext = NULL; |
fFactory = NULL; |