diff options
author | edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-10 23:36:56 +0000 |
---|---|---|
committer | edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-10 23:36:56 +0000 |
commit | 8bad7375d7e0ebe28af4d905665f34227843bd16 (patch) | |
tree | 45851e2527f73a713b48dc27fc9d6582fb03f20e /experimental/PdfViewer | |
parent | c8b3037eeb15936285767ed07528efb4263edaaa (diff) |
pdfviewer: ignore more bad stauff in pdfs
Review URL: https://codereview.chromium.org/18112023
git-svn-id: http://skia.googlecode.com/svn/trunk@9990 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/PdfViewer')
-rw-r--r-- | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp | 15 | ||||
-rw-r--r-- | experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp | 5 |
2 files changed, 13 insertions, 7 deletions
diff --git a/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp b/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp index 7a8ba6fbeb..8bd14ccfd1 100644 --- a/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp +++ b/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp @@ -103,14 +103,17 @@ SkNativeParsedPDF::SkNativeParsedPDF(const char* path) if (fRootCatalogRef) { fRootCatalog = (SkPdfCatalogDictionary*)resolveReference(fRootCatalogRef); - SkPdfPageTreeNodeDictionary* tree = fRootCatalog->Pages(this); - - fillPages(tree); - } else { - // TODO(edisonn): corrupted pdf, read it from beginning and rebuild (xref, trailer, or just reall all objects) - // 0 pages + if (fRootCatalog->isDictionary() && fRootCatalog->valid()) { + SkPdfPageTreeNodeDictionary* tree = fRootCatalog->Pages(this); + if (tree && tree->isDictionary() && tree->valid()) { + fillPages(tree); + } + } } + // TODO(edisonn): corrupted pdf, read it from beginning and rebuild (xref, trailer, or just reall all objects) + // 0 pages + // now actually read all objects if we want, or do it lazyly // and resolve references?... or not ... } diff --git a/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp b/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp index 128813297a..604e9fbda4 100644 --- a/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp +++ b/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp @@ -69,7 +69,8 @@ static unsigned char* readArray(unsigned char* start, unsigned char* end, SkPdfO array->appendInArray(newObj); } // TODO(edisonn): report not reached, we should never get here - SkASSERT(false); + // TODO(edisonn): there might be a bug here, enable an assert and run it on files + // or it might be that the files were actually corrupted return start; } @@ -170,6 +171,8 @@ static unsigned char* readString(unsigned char* start, unsigned char* end, SkPdf in++; break; } + } else { + in++; } } else { // TODO(edisonn): perf, avoid copy into itself, maybe first do a simple scan until found backslash ? |