Validate shading pattern's ColorSpace. It cannot be a Pattern CS.

Bug: chromium:795251
Change-Id: I6c4fd75a5afd16ced499d031f9b535f8c6828854
Reviewed-on: https://pdfium-review.googlesource.com/21410
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp
index 542c405..585a925 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp
@@ -89,6 +89,11 @@
 
   CPDF_DocPageData* pDocPageData = document()->GetPageData();
   m_pCS = pDocPageData->GetColorSpace(pCSObj, nullptr);
+  // The color space cannot be a Pattern space, according to the PDF 1.7 spec,
+  // page 305.
+  if (m_pCS->GetFamily() == PDFCS_PATTERN)
+    return false;
+
   if (m_pCS)
     m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray());