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

Unified Diff: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp

Issue 20004007: pdfviewer: don't crash if the xref is corrupted. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | « experimental/PdfViewer/SkPdfFont.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp
===================================================================
--- experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp (revision 10286)
+++ experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp (working copy)
@@ -291,6 +291,9 @@
}
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 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 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);
« no previous file with comments | « experimental/PdfViewer/SkPdfFont.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698