diff options
author | 2013-07-23 20:47:05 +0000 | |
---|---|---|
committer | 2013-07-23 20:47:05 +0000 | |
commit | b44334c1c07f307f3e2dbb9ee4ace4c14860a345 (patch) | |
tree | 9e4c878408af79249da4bb0316f45c574fe91888 /experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp | |
parent | 70d75ca764e16e15f016e423b85a0fa2a29fb8c7 (diff) |
pdfviewer: don't crash if the xref is corrupted.
Review URL: https://codereview.chromium.org/20004007
git-svn-id: http://skia.googlecode.com/svn/trunk@10293 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp')
-rw-r--r-- | experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp b/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp index 4798031808..cc5788bfd7 100644 --- a/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp +++ b/experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp @@ -291,6 +291,9 @@ static int readStringLength(int level, const unsigned char* start, const unsigne } static const unsigned char* readString(int level, const unsigned char* start, const unsigned char* end, SkPdfObject* str, SkPdfAllocator* allocator) { + if (!allocator) { + return end; + } int outLength = readStringLength(level, start, end); // TODO(edisonn): optimize the allocation, don't allocate new string, but put it in a preallocated buffer unsigned char* out = (unsigned char*)allocator->alloc(outLength); @@ -434,6 +437,9 @@ static int readHexStringLength(int level, const unsigned char* start, const unsi } static const unsigned char* readHexString(int level, const unsigned char* start, const unsigned char* end, SkPdfObject* str, SkPdfAllocator* allocator) { + if (!allocator) { + return end; + } int outLength = readHexStringLength(level, start, end); // TODO(edisonn): optimize the allocation, don't allocate new string, but put it in a preallocated buffer unsigned char* out = (unsigned char*)allocator->alloc(outLength); @@ -556,6 +562,9 @@ static int readNameLength(int level, const unsigned char* start, const unsigned } static const unsigned char* readName(int level, const unsigned char* start, const unsigned char* end, SkPdfObject* name, SkPdfAllocator* allocator) { + if (!allocator) { + return end; + } int outLength = readNameLength(level, start, end); // TODO(edisonn): optimize the allocation, don't allocate new string, but put it in a preallocated buffer unsigned char* out = (unsigned char*)allocator->alloc(outLength); |