summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-09 18:12:34 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-09 18:12:34 +0000
commite797c6f8e64667be460742a78bff8e7818217172 (patch)
tree5ccfafd42cd5dc335d5a3cbe111def97296f6334
parent6169c37cb94e78d05641a9b7a920912460cd20da (diff)
downloadpdfium-e797c6f8e64667be460742a78bff8e7818217172.tar.xz
Fix a C-style cast in FPDFPage_TransFormWithClip().
There is no guarantee that CFX_Matrix and FS_MATRIX are the same. Also change the code to do some early returns. Change-Id: I6b5b42cafe370cd43ec1dd5885bba8e37c4a1341 Reviewed-on: https://pdfium-review.googlesource.com/c/43611 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp46
1 files changed, 24 insertions, 22 deletions
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 52b9fd41df..87f39ed072 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -158,28 +158,30 @@ FPDFPage_TransFormWithClip(FPDF_PAGE page,
// Need to transform the patterns as well.
CPDF_Dictionary* pRes =
pPageDict->GetDictFor(pdfium::page_object::kResources);
- if (pRes) {
- CPDF_Dictionary* pPattenDict = pRes->GetDictFor("Pattern");
- if (pPattenDict) {
- for (const auto& it : *pPattenDict) {
- CPDF_Object* pObj = it.second.get();
- if (pObj->IsReference())
- pObj = pObj->GetDirect();
-
- CPDF_Dictionary* pDict = nullptr;
- if (pObj->IsDictionary())
- pDict = pObj->AsDictionary();
- else if (CPDF_Stream* pObjStream = pObj->AsStream())
- pDict = pObjStream->GetDict();
- else
- continue;
-
- CFX_Matrix m = pDict->GetMatrixFor("Matrix");
- CFX_Matrix t = *(CFX_Matrix*)matrix;
- m.Concat(t);
- pDict->SetMatrixFor("Matrix", m);
- }
- }
+ if (!pRes)
+ return true;
+
+ CPDF_Dictionary* pPattenDict = pRes->GetDictFor("Pattern");
+ if (!pPattenDict)
+ return true;
+
+ for (const auto& it : *pPattenDict) {
+ CPDF_Object* pObj = it.second.get();
+ if (pObj->IsReference())
+ pObj = pObj->GetDirect();
+
+ CPDF_Dictionary* pDict = nullptr;
+ if (pObj->IsDictionary())
+ pDict = pObj->AsDictionary();
+ else if (CPDF_Stream* pObjStream = pObj->AsStream())
+ pDict = pObjStream->GetDict();
+ else
+ continue;
+
+ CFX_Matrix m = pDict->GetMatrixFor("Matrix");
+ m.Concat(CFX_Matrix(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e,
+ matrix->f));
+ pDict->SetMatrixFor("Matrix", m);
}
return true;