Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: src/pdf/SkPDFStream.cpp

Issue 23437004: [PDF] Fix printing crashes caused by font streams that don't support getMemoryBase(). (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add comment Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFStream.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFStream.cpp
diff --git a/src/pdf/SkPDFStream.cpp b/src/pdf/SkPDFStream.cpp
index 4ae1f39d26f18dc9783c5bcf1decb75c7a828b05..e570976403382cac79dfcb327030391fa9a08253 100644
--- a/src/pdf/SkPDFStream.cpp
+++ b/src/pdf/SkPDFStream.cpp
@@ -18,10 +18,8 @@ static bool skip_compression(SkPDFCatalog* catalog) {
SkPDFDocument::kFavorSpeedOverSize_Flags);
}
-SkPDFStream::SkPDFStream(SkStream* stream)
- : fState(kUnused_State),
- fData(stream) {
- SkSafeRef(stream);
+SkPDFStream::SkPDFStream(SkStream* stream) : fState(kUnused_State) {
+ setData(stream);
}
SkPDFStream::SkPDFStream(SkData* data) : fState(kUnused_State) {
@@ -30,9 +28,8 @@ SkPDFStream::SkPDFStream(SkData* data) : fState(kUnused_State) {
SkPDFStream::SkPDFStream(const SkPDFStream& pdfStream)
: SkPDFDict(),
- fState(kUnused_State),
- fData(pdfStream.fData.get()) {
- fData.get()->ref();
+ fState(kUnused_State) {
+ setData(pdfStream.fData.get());
bool removeLength = true;
// Don't uncompress an already compressed stream, but we could.
if (pdfStream.fState == kCompressed_State) {
@@ -64,7 +61,8 @@ void SkPDFStream::emitObject(SkWStream* stream, SkPDFCatalog* catalog,
this->INHERITED::emitObject(stream, catalog, false);
stream->writeText(" stream\n");
- stream->write(fData->getMemoryBase(), fData->getLength());
+ stream->writeStream(fData.get(), fData->getLength());
+ fData->rewind();
stream->writeText("\nendstream");
}
@@ -89,6 +87,11 @@ void SkPDFStream::setData(SkData* data) {
}
void SkPDFStream::setData(SkStream* stream) {
+ // Code assumes that the stream starts at the beginning and is rewindable.
+ if (stream) {
+ SkASSERT(stream->getPosition() == 0);
+ SkASSERT(stream->rewind());
+ }
fData.reset(stream);
SkSafeRef(stream);
}
« no previous file with comments | « src/pdf/SkPDFStream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698