Index: src/core/SkMallocPixelRef.cpp |
diff --git a/src/core/SkMallocPixelRef.cpp b/src/core/SkMallocPixelRef.cpp |
index 9f9ffd8db7401994ad203caf51a1f080795738be..b65197fac852ae7e5dceb3bf4ed4764dc92cd087 100644 |
--- a/src/core/SkMallocPixelRef.cpp |
+++ b/src/core/SkMallocPixelRef.cpp |
@@ -143,8 +143,13 @@ SkMallocPixelRef::SkMallocPixelRef(SkFlattenableReadBuffer& buffer) |
{ |
fRB = buffer.read32(); |
size_t size = this->info().getSafeSize(fRB); |
- fStorage = sk_malloc_throw(size); |
- buffer.readByteArray(fStorage, size); |
+ if (buffer.validateAvailable(size)) { |
+ fStorage = sk_malloc_throw(size); |
+ buffer.readByteArray(fStorage, size); |
+ } else { |
+ fStorage = NULL; |
+ } |
+ |
if (buffer.readBool()) { |
fCTable = SkNEW_ARGS(SkColorTable, (buffer)); |
} else { |