Remove more ifndef XFA cases

Remove FXFT_Clear_Face_External_Stream() calls, period. This would cause
FT to try to free memory allocated by the caller, with potentially a
different allocator. If we're leaking, msan will find it, and we can
deal with it properly rather than trying to force FT to tidy after us.

Always call SetView(), if we have a PDF page.  At worst, the link won't
be used in the XFA case.

Always return 0 for the null document permissions.  If we don't have a
document, then we can't dynamically tell if its an XFA doc, so there's
no reason to believe it should have all permissions.  If there is an
XFA doc under the covers, then the extension will give us the value.


Change-Id: I6e3fb589eda722786567d96288cb35f43643437b
Reviewed-on: https://pdfium-review.googlesource.com/33370
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index bee1d78..08e33d6 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -317,14 +317,9 @@
 #endif  // PDF_ENABLE_XFA
 
 CFX_Font::~CFX_Font() {
-  if (m_Face) {
-#ifndef PDF_ENABLE_XFA
-    if (FXFT_Get_Face_External_Stream(m_Face)) {
-      FXFT_Clear_Face_External_Stream(m_Face);
-    }
-#endif  // PDF_ENABLE_XFA
+  if (m_Face)
     DeleteFace();
-  }
+
 #if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
   ReleasePlatformResource();
 #endif
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index 5cb5f2c..06d197d 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -38,19 +38,18 @@
     CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
     CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
     pPDFInterForm->FixPageFields(pPDFPage);
-#ifndef PDF_ENABLE_XFA
     pPDFPage->SetView(this);
-#endif  // PDF_ENABLE_XFA
   }
 }
 
 CPDFSDK_PageView::~CPDFSDK_PageView() {
-#ifndef PDF_ENABLE_XFA
-  // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to
-  // be freed, which will cause issues if we try to cleanup the pageview pointer
-  // in |m_page|. So, reset the pageview pointer before doing anything else.
-  m_page->AsPDFPage()->SetView(nullptr);
-#endif  // PDF_ENABLE_XFA
+  CPDF_Page* pPDFPage = ToPDFPage(m_page);
+  if (pPDFPage) {
+    // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to
+    // be freed, which will cause issues if we try to cleanup the pageview ptr
+    // in |m_page|. So, reset the pageview pointer before doing anything else.
+    pPDFPage->SetView(nullptr);
+  }
 
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 91072d2..feffaeb 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -308,16 +308,7 @@
 FPDF_EXPORT unsigned long FPDF_CALLCONV
 FPDF_GetDocPermissions(FPDF_DOCUMENT document) {
   CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
-  // https://bugs.chromium.org/p/pdfium/issues/detail?id=499
-  if (!pDoc) {
-#ifndef PDF_ENABLE_XFA
-    return 0;
-#else   // PDF_ENABLE_XFA
-    return 0xFFFFFFFF;
-#endif  // PDF_ENABLE_XFA
-  }
-
-  return pDoc->GetUserPermissions();
+  return pDoc ? pDoc->GetUserPermissions() : 0;
 }
 
 FPDF_EXPORT int FPDF_CALLCONV