Handle negative rotation case in CPDF_Page::GetDisplayMatrix()

Catch the default case in a switch-statement and just return a
CFX_Matrix of all zeroes.

Change-Id: I03b98b23a02aa6138f28c5ac79c9cbcf8fb97cf6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/132230
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index 795fd19..556fed7 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -128,20 +128,19 @@
     return CFX_Matrix();
   }
 
-  float x0 = 0;
-  float y0 = 0;
-  float x1 = 0;
-  float y1 = 0;
-  float x2 = 0;
-  float y2 = 0;
-  rotation %= 4;
+  float x0;
+  float y0;
+  float x1;
+  float y1;
+  float x2;
+  float y2;
   // This code implicitly inverts the y-axis to account for page coordinates
   // pointing up and bitmap coordinates pointing down. (x0, y0) is the base
   // point, (x1, y1) is that point translated on y and (x2, y2) is the point
   // translated on x. On rotation = 0, y0 is rect.bottom and the translation
   // to get y1 is performed as negative. This results in the desired
   // transformation.
-  switch (rotation) {
+  switch (rotation % 4) {
     case 0:
       x0 = rect.left;
       y0 = rect.bottom;
@@ -174,6 +173,11 @@
       x2 = rect.right;
       y2 = rect.top;
       break;
+    default:
+      CHECK_LT(rotation, 0);
+      // Handing this with `rotation += 4` breaks public API compatibility. So
+      // just return early here without doing all the matrix calculations below.
+      return CFX_Matrix(0, 0, 0, 0, 0, 0);
   }
   CFX_Matrix matrix((x2 - x0) / page_size_.width, (y2 - y0) / page_size_.width,
                     (x1 - x0) / page_size_.height,