Index: experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp |
=================================================================== |
--- experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp (revision 10010) |
+++ experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp (working copy) |
@@ -75,11 +75,16 @@ |
FILE* file = fopen(path, "r"); |
fContentLength = getFileSize(path); |
fFileContent = new unsigned char[fContentLength + 1]; |
- fread(fFileContent, fContentLength, 1, file); |
+ bool ok = (0 != fread(fFileContent, fContentLength, 1, file)); |
fFileContent[fContentLength] = '\0'; |
fclose(file); |
file = NULL; |
+ if (!ok) { |
+ // TODO(edisonn): report read error |
+ return; // Doc will have 0 pages |
+ } |
+ |
unsigned char* eofLine = lineHome(fFileContent, fFileContent + fContentLength - 1); |
unsigned char* xrefByteOffsetLine = previousLineHome(fFileContent, eofLine); |
unsigned char* xrefstartKeywordLine = previousLineHome(fFileContent, xrefByteOffsetLine); |