Avoid a NOTREACHED() in CFX_DIBitmap::CompositeMask().

CFX_DIBitmap::CompositeMask() expects the input bitmap to be a mask.
CPDF_RenderStatus::ProcessType3Text() calls CompositeMask() without
checking this. Add the check to avoid hitting a NOTREACHED().

Bug: chromium:1241587
Change-Id: I9aab030b3091bdd069a389f4e00b623f19521ad3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84251
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index acd5928..2a1b40a 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1059,7 +1059,7 @@
 
   pBitmap->Clear(0);
   for (const TextGlyphPos& glyph : glyphs) {
-    if (!glyph.m_pGlyph)
+    if (!glyph.m_pGlyph || !glyph.m_pGlyph->GetBitmap()->IsMaskFormat())
       continue;
 
     Optional<CFX_Point> point = glyph.GetOrigin({rect.left, rect.top});
diff --git a/testing/resources/pixel/bug_1241587.in b/testing/resources/pixel/bug_1241587.in
new file mode 100644
index 0000000..61b1637
--- /dev/null
+++ b/testing/resources/pixel/bug_1241587.in
@@ -0,0 +1,78 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /Pages 2 0 R
+>>
+endobj
+{{object 2 0}} <<
+  /Type /Pages
+  /Count 1
+  /Kids [3 0 R]
+>>
+endobj
+{{object 3 0}} <<
+  /Type /Page
+  /Parent 2 0 R
+  /MediaBox [0 0 100 100]
+  /Resources <<
+    /Font <<
+      /F1 5 0 R
+    >>
+  >>
+  /Contents 4 0 R
+>>
+endobj
+{{object 4 0}} <<
+  {{streamlen}}
+>>
+stream
+BT
+/F1 1 Tf
+(s) Tj
+ET
+endstream
+endobj
+{{object 5 0}} <<
+  /Type /Font
+  /Subtype /Type3
+  /CharProcs <<
+    /s 6 0 R
+  >>
+  /Encoding <<
+    /Differences [115 /s]
+  >>
+  /FirstChar 115
+  /FontBBox [0 0 1 2]
+  /LastChar 115
+  /Resources <<
+    /XObject <<
+      /Im1 7 0 R
+    >>
+  >>
+>>
+endobj
+{{object 6 0}} <<
+  {{streamlen}}
+>>
+stream
+/Im1 Do
+endstream
+endobj
+{{object 7 0}} <<
+  /Type /XObject
+  /Subtype /Image
+  /Width 50
+  /Height 50
+  /BitsPerComponent 8
+  /ColorSpace /DeviceRGB
+  /Filter [/ASCIIHexDecode /FlateDecode]
+  {{streamlen}}
+>>
+stream
+789cedc2310d00000c03a07f2aaab3ea7bcf03842655555555555555f5bf01cc7818dc
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/pixel/bug_1241587_expected.pdf.0.png b/testing/resources/pixel/bug_1241587_expected.pdf.0.png
new file mode 100644
index 0000000..319932a
--- /dev/null
+++ b/testing/resources/pixel/bug_1241587_expected.pdf.0.png
Binary files differ