Index: src/core/SkPictureData.cpp |
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp |
index 896c2e6bf324fcd5f17b9ed9c731fb7736086b6b..bc152829189b098c2eecd0014329bb7b3ce3ad60 100644 |
--- a/src/core/SkPictureData.cpp |
+++ b/src/core/SkPictureData.cpp |
@@ -395,6 +395,7 @@ bool SkPictureData::parseStreamTag(SkStream* stream, |
return false; |
} |
+ /* Should we use SkValidatingReadBuffer instead? */ |
scroggo
2014/11/12 18:24:47
If we're going to check isValid, absolutely! Other
|
SkReadBuffer buffer(storage.get(), size); |
buffer.setFlags(pictInfoFlagsToReadBufferFlags(fInfo.fFlags)); |
buffer.setVersion(fInfo.fVersion); |
@@ -403,13 +404,16 @@ bool SkPictureData::parseStreamTag(SkStream* stream, |
fTFPlayback.setupBuffer(buffer); |
buffer.setBitmapDecoder(proc); |
- while (!buffer.eof()) { |
+ while (!buffer.eof() && buffer.isValid()) { |
tag = buffer.readUInt(); |
size = buffer.readUInt(); |
if (!this->parseBufferTag(buffer, tag, size)) { |
return false; |
} |
} |
+ if (!buffer.isValid()) { |
scroggo
2014/11/12 18:24:47
Do we need both checks?
Is it possible for isVali
|
+ return false; |
+ } |
SkDEBUGCODE(haveBuffer = true;) |
} break; |
} |
@@ -424,8 +428,11 @@ bool SkPictureData::parseBufferTag(SkReadBuffer& buffer, |
fBitmaps = SkTRefArray<SkBitmap>::Create(size); |
for (int i = 0; i < count; ++i) { |
SkBitmap* bm = &fBitmaps->writableAt(i); |
- buffer.readBitmap(bm); |
- bm->setImmutable(); |
+ if (buffer.readBitmap(bm)) { |
+ bm->setImmutable(); |
+ } else { |
+ return false; |
+ } |
} |
} break; |
case SK_PICT_PAINT_BUFFER_TAG: { |