aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/PdfViewer/pdfparser
diff options
context:
space:
mode:
authorGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-07 18:04:15 +0000
committerGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-07 18:04:15 +0000
commite57c62d039cbd67a4e52776b3e95c5d002b818d2 (patch)
tree3755ce95565d1ca30fef65825c4a6be273323c95 /experimental/PdfViewer/pdfparser
parentc6233285be7b5151d5a87eba5547b0d953b4f50c (diff)
pdfviewer: fix font rotation issues
Review URL: https://codereview.chromium.org/22407005 git-svn-id: http://skia.googlecode.com/svn/trunk@10617 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/PdfViewer/pdfparser')
-rw-r--r--experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp b/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp
index 333b0a25db..2e7e670ce9 100644
--- a/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp
+++ b/experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp
@@ -90,21 +90,22 @@ SkNativeParsedPDF::SkNativeParsedPDF(const char* path)
, fRootCatalog(NULL) {
gDoc = this;
FILE* file = fopen(path, "r");
- size_t size = getFileSize(path);
- void* content = sk_malloc_throw(size);
- bool ok = (0 != fread(content, size, 1, file));
- fclose(file);
- file = NULL;
+ // TODO(edisonn): put this in a function that can return NULL
+ if (file) {
+ size_t size = getFileSize(path);
+ void* content = sk_malloc_throw(size);
+ bool ok = (0 != fread(content, size, 1, file));
+ fclose(file);
+ if (!ok) {
+ sk_free(content);
+ // TODO(edisonn): report read error
+ // TODO(edisonn): not nice to return like this from constructor, create a static
+ // function that can report NULL for failures.
+ return; // Doc will have 0 pages
+ }
- if (!ok) {
- sk_free(content);
- // TODO(edisonn): report read error
- // TODO(edisonn): not nice to return like this from constructor, create a static
- // function that can report NULL for failures.
- return; // Doc will have 0 pages
+ init(content, size);
}
-
- init(content, size);
}
void SkNativeParsedPDF::init(const void* bytes, size_t length) {