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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 2006793003: PDF: Always call FPDFAvail_IsDocAvail() when loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better fix? Created 4 years, 7 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 | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 5ee7e623ac43e20b3098cb3097ff2bec45443f99..c8a46a018f0be171cf2317fc6ff92f9f452ed765 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -298,7 +298,7 @@ FPDF_SYSFONTINFO g_font_info = {
};
#endif // defined(OS_LINUX)
-PDFiumEngine* g_engine_for_unsupported;
+PDFiumEngine* g_engine_for_unsupported = nullptr;
void Unsupported_Handler(UNSUPPORT_INFO*, int type) {
if (!g_engine_for_unsupported) {
@@ -1049,6 +1049,7 @@ void PDFiumEngine::OnPartialDocumentLoaded() {
void PDFiumEngine::OnPendingRequestComplete() {
if (!doc_ || !form_) {
+ DCHECK(fpdf_availability_);
Lei Zhang 2016/05/25 17:16:36 I'm pretty sure OnPartialDocumentLoaded() has to b
Wei Li 2016/05/25 22:37:38 Acknowledged.
LoadDocument();
return;
}
@@ -2430,11 +2431,17 @@ bool PDFiumEngine::TryLoadingDoc(const std::string& password,
} else {
doc_ = FPDFAvail_GetDocument(fpdf_availability_, password_cstr);
}
+ if (!doc_) {
+ if (FPDF_GetLastError() == FPDF_ERR_PASSWORD)
+ *needs_password = true;
+ return false;
+ }
- if (!doc_ && FPDF_GetLastError() == FPDF_ERR_PASSWORD)
- *needs_password = true;
-
- return !!doc_;
+ // Always call FPDFAvail_IsDocAvail() so PDFium initializes internal data
+ // structures.
+ int avail = FPDFAvail_IsDocAvail(fpdf_availability_, &download_hints_);
Lei Zhang 2016/05/25 17:16:36 I decided to (potentially) call this a second time
Wei Li 2016/05/25 22:37:38 Would this approach be fragile? In samples/pdfium_
Lei Zhang 2016/06/14 17:53:56 Whether FPDFAvail_IsDocAvail() ends up reading the
Wei Li 2016/06/14 23:33:42 I think the fix is in right direction. But we need
+ DCHECK_EQ(PDF_DATA_AVAIL, avail);
+ return true;
}
void PDFiumEngine::GetPasswordAndLoad() {
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698