Index: src/core/SkPictureData.cpp |
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp |
index a2d10e3b9b0e1f67ceea0300983c29584db7e9b5..656515830c850b73cebd64b56e94bd94791c7898 100644 |
--- a/src/core/SkPictureData.cpp |
+++ b/src/core/SkPictureData.cpp |
@@ -390,14 +390,13 @@ bool SkPictureData::parseStreamTag(SkStream* stream, |
SkDEBUGCODE(bool haveBuffer = false;) |
switch (tag) { |
- case SK_PICT_READER_TAG: { |
- SkAutoMalloc storage(size); |
- if (stream->read(storage.get(), size) != size) { |
+ case SK_PICT_READER_TAG: |
+ SkASSERT(NULL == fOpData); |
+ fOpData = SkData::NewFromStream(stream, size); |
+ if (!fOpData) { |
return false; |
} |
- SkASSERT(NULL == fOpData); |
- fOpData = SkData::NewFromMalloc(storage.detach(), size); |
- } break; |
+ break; |
case SK_PICT_FACTORY_TAG: { |
SkASSERT(!haveBuffer); |
// Remove this code when v21 and below are no longer supported. At the |
@@ -538,13 +537,13 @@ bool SkPictureData::parseBufferTag(SkReadBuffer& buffer, |
} |
} break; |
case SK_PICT_READER_TAG: { |
- SkAutoMalloc storage(size); |
- if (!buffer.readByteArray(storage.get(), size) || |
+ SkAutoDataUnref data(SkData::NewUninitialized(size)); |
+ if (!buffer.readByteArray(data->writable_data(), size) || |
!buffer.validate(NULL == fOpData)) { |
return false; |
} |
SkASSERT(NULL == fOpData); |
- fOpData = SkData::NewFromMalloc(storage.detach(), size); |
+ fOpData = data.detach(); |
} break; |
case SK_PICT_PICTURE_TAG: { |
if (!buffer.validate((0 == fPictureCount) && (NULL == fPictureRefs))) { |