Reorder code in FPDFPage_TransFormWithClip().

Do all the checks that can cause the function to return false first.

Change-Id: I7007f7e328d9e46472545a9fdb6f5c007b4a2d03
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/56297
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index fe49345..1aa9d92 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -171,6 +171,15 @@
   if (!pPage)
     return false;
 
+  CPDF_Dictionary* pPageDict = pPage->GetDict();
+  CPDF_Object* pContentObj = GetPageContent(pPageDict);
+  if (!pContentObj)
+    return false;
+
+  CPDF_Document* pDoc = pPage->GetDocument();
+  if (!pDoc)
+    return false;
+
   std::ostringstream text_buf;
   text_buf << "q ";
 
@@ -188,15 +197,6 @@
     text_buf << m << " cm ";
   }
 
-  CPDF_Dictionary* pPageDict = pPage->GetDict();
-  CPDF_Object* pContentObj = GetPageContent(pPageDict);
-  if (!pContentObj)
-    return false;
-
-  CPDF_Document* pDoc = pPage->GetDocument();
-  if (!pDoc)
-    return false;
-
   CPDF_Stream* pStream =
       pDoc->NewIndirect<CPDF_Stream>(nullptr, 0, pDoc->New<CPDF_Dictionary>());
   pStream->SetDataFromStringstream(&text_buf);