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

Side by Side Diff: experimental/PdfViewer/pdfparser/native/SkPdfNativeDoc.cpp

Issue 72053002: pdfviewer: readobject can return null, and catalog can be null (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reupload Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPdfNativeDoc.h" 8 #include "SkPdfNativeDoc.h"
9 9
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 readTrailer(trailerStart, xrefstartKeywordLine, storeCatalog, &xrefB yteOffset, false); 133 readTrailer(trailerStart, xrefstartKeywordLine, storeCatalog, &xrefB yteOffset, false);
134 storeCatalog = false; 134 storeCatalog = false;
135 } 135 }
136 } 136 }
137 137
138 // TODO(edisonn): warn/error expect fObjects[fRefCatalogId].fGeneration == f RefCatalogGeneration 138 // TODO(edisonn): warn/error expect fObjects[fRefCatalogId].fGeneration == f RefCatalogGeneration
139 // TODO(edisonn): security, verify that SkPdfCatalogDictionary is indeed usi ng mapper 139 // TODO(edisonn): security, verify that SkPdfCatalogDictionary is indeed usi ng mapper
140 140
141 if (fRootCatalogRef) { 141 if (fRootCatalogRef) {
142 fRootCatalog = (SkPdfCatalogDictionary*)resolveReference(fRootCatalogRef ); 142 fRootCatalog = (SkPdfCatalogDictionary*)resolveReference(fRootCatalogRef );
143 if (fRootCatalog->isDictionary() && fRootCatalog->valid()) { 143 if (fRootCatalog != NULL && fRootCatalog->isDictionary() && fRootCatalog ->valid()) {
144 SkPdfPageTreeNodeDictionary* tree = fRootCatalog->Pages(this); 144 SkPdfPageTreeNodeDictionary* tree = fRootCatalog->Pages(this);
145 if (tree && tree->isDictionary() && tree->valid()) { 145 if (tree && tree->isDictionary() && tree->valid()) {
146 fillPages(tree); 146 fillPages(tree);
147 } 147 }
148 } 148 }
149 } 149 }
150 150
151 if (pages() == 0) { 151 if (pages() == 0) {
152 // TODO(edisonn): probably it would be better to return NULL and make a clean document. 152 // TODO(edisonn): probably it would be better to return NULL and make a clean document.
153 loadWithoutXRef(); 153 loadWithoutXRef();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 SkPdfNativeObject* obj = object(i); 215 SkPdfNativeObject* obj = object(i);
216 SkPdfNativeObject* root = (obj && obj->isDictionary()) ? obj->get("R oot") : NULL; 216 SkPdfNativeObject* root = (obj && obj->isDictionary()) ? obj->get("R oot") : NULL;
217 if (root && root->isReference()) { 217 if (root && root->isReference()) {
218 fRootCatalogRef = root; 218 fRootCatalogRef = root;
219 } 219 }
220 } 220 }
221 } 221 }
222 222
223 if (fRootCatalogRef) { 223 if (fRootCatalogRef) {
224 fRootCatalog = (SkPdfCatalogDictionary*)resolveReference(fRootCatalogRef ); 224 fRootCatalog = (SkPdfCatalogDictionary*)resolveReference(fRootCatalogRef );
225 if (fRootCatalog->isDictionary() && fRootCatalog->valid()) { 225 if (fRootCatalog != NULL && fRootCatalog->isDictionary() && fRootCatalog ->valid()) {
226 SkPdfPageTreeNodeDictionary* tree = fRootCatalog->Pages(this); 226 SkPdfPageTreeNodeDictionary* tree = fRootCatalog->Pages(this);
227 if (tree && tree->isDictionary() && tree->valid()) { 227 if (tree && tree->isDictionary() && tree->valid()) {
228 fillPages(tree); 228 fillPages(tree);
229 } 229 }
230 } 230 }
231 } 231 }
232 232
233 233
234 } 234 }
235 235
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // here unless we check for resolved reference on next line. 576 // here unless we check for resolved reference on next line.
577 // Determine if the pdf is corrupted, or we have a bug here. 577 // Determine if the pdf is corrupted, or we have a bug here.
578 578
579 // Avoids recursive calls 579 // Avoids recursive calls
580 fObjects[id].fIsReferenceResolved = true; 580 fObjects[id].fIsReferenceResolved = true;
581 581
582 if (fObjects[id].fObj == NULL) { 582 if (fObjects[id].fObj == NULL) {
583 fObjects[id].fObj = readObject(id); 583 fObjects[id].fObj = readObject(id);
584 } 584 }
585 585
586 if (fObjects[id].fResolvedReference == NULL) { 586 if (fObjects[id].fObj != NULL && fObjects[id].fResolvedReference == NULL ) {
587 if (!fObjects[id].fObj->isReference()) { 587 if (!fObjects[id].fObj->isReference()) {
588 fObjects[id].fResolvedReference = fObjects[id].fObj; 588 fObjects[id].fResolvedReference = fObjects[id].fObj;
589 } else { 589 } else {
590 fObjects[id].fResolvedReference = resolveReference(fObjects[id]. fObj); 590 fObjects[id].fResolvedReference = resolveReference(fObjects[id]. fObj);
591 } 591 }
592 } 592 }
593 593
594 return fObjects[id].fResolvedReference; 594 return fObjects[id].fResolvedReference;
595 } 595 }
596 596
597 return (SkPdfNativeObject*)ref; 597 return (SkPdfNativeObject*)ref;
598 } 598 }
599 599
600 size_t SkPdfNativeDoc::bytesUsed() const { 600 size_t SkPdfNativeDoc::bytesUsed() const {
601 return fAllocator->bytesUsed() + 601 return fAllocator->bytesUsed() +
602 fContentLength + 602 fContentLength +
603 fObjects.count() * sizeof(PublicObjectEntry) + 603 fObjects.count() * sizeof(PublicObjectEntry) +
604 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + 604 fPages.count() * sizeof(SkPdfPageObjectDictionary*) +
605 sizeof(*this); 605 sizeof(*this);
606 } 606 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698