aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/PdfViewer/pdfparser
diff options
context:
space:
mode:
authorGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-23 21:05:49 +0000
committerGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-23 21:05:49 +0000
commit1f080163ac58e0a5a621a720de5fc63e7b736765 (patch)
tree50e158bb09b1ea152e6a88b43772b1b55ce419aa /experimental/PdfViewer/pdfparser
parentb44334c1c07f307f3e2dbb9ee4ace4c14860a345 (diff)
pdfviewer: more simple fixed to prevent crashes
Review URL: https://codereview.chromium.org/19625008 git-svn-id: http://skia.googlecode.com/svn/trunk@10294 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/PdfViewer/pdfparser')
-rw-r--r--experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp4
-rw-r--r--experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp11
2 files changed, 12 insertions, 3 deletions
diff --git a/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp b/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp
index ac543040b0..4fb7f8895b 100644
--- a/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp
+++ b/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp
@@ -189,9 +189,9 @@ long SkNativeParsedPDF::readTrailer(const unsigned char* trailerStart, const uns
// TODO(edisonn): use null allocator, and let it just fail if memory
// needs allocated (but no crash)!
const unsigned char* current =
- nextObject(0, trailerStart, trailerEnd, &trailerKeyword, fAllocator, NULL);
+ nextObject(0, trailerStart, trailerEnd, &trailerKeyword, NULL, NULL);
- if (strlen("trailer") != trailerKeyword.len() &&
+ if (!trailerKeyword.isKeyword() || strlen("trailer") != trailerKeyword.len() ||
strncmp(trailerKeyword.c_str(), "trailer", strlen("trailer")) != 0) {
// TODO(edisonn): report warning, rebuild trailer from objects.
return -1;
diff --git a/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp b/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp
index cc5788bfd7..7d8bcb695a 100644
--- a/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp
+++ b/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp
@@ -125,6 +125,11 @@ static const unsigned char* endOfPdfToken(int level, const unsigned char* start,
// last elem has to be ]
static const unsigned char* readArray(int level, const unsigned char* start, const unsigned char* end, SkPdfObject* array, SkPdfAllocator* allocator, SkNativeParsedPDF* doc) {
+ if (allocator == NULL) {
+ // TODO(edisonn): report/warning error
+ return end;
+ }
+
TRACE_INDENT(level, "Array");
while (start < end) {
// skip white spaces
@@ -208,7 +213,7 @@ static const unsigned char* readString(int level, const unsigned char* start, co
break;
case 'f':
- *out = kFF_PdfWhiteSpace;
+ if (hasOut) { *out = kFF_PdfWhiteSpace; }
out++;
in += 2;
break;
@@ -693,6 +698,10 @@ static const unsigned char* readInlineImageStream(int level, const unsigned char
}
static const unsigned char* readDictionary(int level, const unsigned char* start, const unsigned char* end, SkPdfObject* dict, SkPdfAllocator* allocator, SkNativeParsedPDF* doc) {
+ if (allocator == NULL) {
+ // TODO(edisonn): report/warning error
+ return end;
+ }
TRACE_INDENT(level, "Dictionary");
SkPdfObject::makeEmptyDictionary(dict);