Fix a crash in FPDFPage_TransFormWithClip().

Change-Id: I8874b125cee2f947c86c13af95832c38be8eb2be
Reviewed-on: https://pdfium-review.googlesource.com/c/47534
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdf_transformpage_embeddertest.cpp b/fpdfsdk/fpdf_transformpage_embeddertest.cpp
index 2619747..2a80e4e 100644
--- a/fpdfsdk/fpdf_transformpage_embeddertest.cpp
+++ b/fpdfsdk/fpdf_transformpage_embeddertest.cpp
@@ -229,3 +229,19 @@
 
   UnloadPage(page);
 }
+
+TEST_F(FPDFTransformEmbedderTest, TransFormWithClipWithPatterns) {
+  const FS_MATRIX half_matrix{0.5, 0, 0, 0.5, 0, 0};
+  const FS_RECTF clip_rect = {0.0f, 0.0f, 20.0f, 10.0f};
+
+  ASSERT_TRUE(OpenDocument("bug_547706.pdf"));
+
+  FPDF_PAGE page = LoadPage(0);
+  ASSERT_TRUE(page);
+
+  EXPECT_TRUE(FPDFPage_TransFormWithClip(page, &half_matrix, nullptr));
+  EXPECT_TRUE(FPDFPage_TransFormWithClip(page, nullptr, &clip_rect));
+  EXPECT_TRUE(FPDFPage_TransFormWithClip(page, &half_matrix, &clip_rect));
+
+  UnloadPage(page);
+}