Corrected the error setting after calling FPDF_LoadDocument()

Currently, if FPDF_LoadDocument() is called on a nonexistent file, the
returned FPDF_DOCUMENT will be null, but FPDF_GetLastError() will return
an error of FPDF_ERR_SUCCESS, i.e. no error.

This CL corrects this behavior by updating the error to be FPDF_ERR_FILE
when the file doesn't exist.

Bug=pdfium:452

Change-Id: I3c3ec3a64e049636ddfb2ba5cb5f2745a0e19b6b
Reviewed-on: https://pdfium-review.googlesource.com/11650
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Jane Liu <janeliulwq@google.com>
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index 964d769..bf8daad 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -275,8 +275,10 @@
 FPDF_DOCUMENT LoadDocumentImpl(
     const CFX_RetainPtr<IFX_SeekableReadStream>& pFileAccess,
     FPDF_BYTESTRING password) {
-  if (!pFileAccess)
+  if (!pFileAccess) {
+    ProcessParseError(CPDF_Parser::FILE_ERROR);
     return nullptr;
+  }
 
   auto pParser = pdfium::MakeUnique<CPDF_Parser>();
   pParser->SetPassword(password);
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp
index 0007587..0e478b4 100644
--- a/fpdfsdk/fpdfview_embeddertest.cpp
+++ b/fpdfsdk/fpdfview_embeddertest.cpp
@@ -30,6 +30,12 @@
   EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document()));
 }
 
+TEST_F(FPDFViewEmbeddertest, LoadNonexistentDocument) {
+  FPDF_DOCUMENT doc = FPDF_LoadDocument("nonexistent_document.pdf", "");
+  ASSERT_FALSE(doc);
+  EXPECT_EQ(static_cast<int>(FPDF_GetLastError()), FPDF_ERR_FILE);
+}
+
 // See bug 465.
 TEST_F(FPDFViewEmbeddertest, EmptyDocument) {
   EXPECT_TRUE(CreateEmptyDocument());