Chromium Code Reviews| Index: core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp |
| diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp |
| index 3295b7f9e034875582758e7efa8cffddfc95c80d..86082357aee10af1a58e9f4b9b88c501cf0b04f1 100644 |
| --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp |
| +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp |
| @@ -671,51 +671,33 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { |
| CFX_ByteString name = GetString(0); |
| if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && |
| m_pLastImage->GetStream()->GetObjNum()) { |
| - AddImage(NULL, m_pLastImage, FALSE); |
| + AddImage(nullptr, m_pLastImage, FALSE); |
| return; |
| } |
| + |
| if (m_Options.m_bTextOnly) { |
| - CPDF_Object* pRes = NULL; |
| - if (m_pResources == NULL) { |
| + CPDF_Object* pRes = nullptr; |
|
Lei Zhang
2015/10/22 21:26:51
move this down to where it's used
Tom Sepez
2015/10/22 21:49:14
nit: Move this down and combine with initializatio
dsinclair
2015/10/26 13:55:44
Done.
dsinclair
2015/10/26 13:55:44
Done.
|
| + if (!m_pResources) |
| return; |
| - } |
| - if (m_pResources == m_pPageResources) { |
| - CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); |
| - if (pList == NULL) { |
| + |
| + CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); |
| + if (!pList) { |
| + if (m_pResources == m_pPageResources || !m_pPageResources) |
| return; |
| - } |
| - pRes = pList->GetElement(name); |
| - if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { |
| + CPDF_Dictionary* pList = m_pPageResources->GetDict(FX_BSTRC("XObject")); |
|
Lei Zhang
2015/10/22 21:26:51
There's a shadow variable here.
Tom Sepez
2015/10/22 21:49:13
Argh, shadowing of pList at 683! This would be a
dsinclair
2015/10/26 13:55:44
Mistake in my simplification. Should not have been
|
| + if (!pList) |
| return; |
| - } |
| - } else { |
| - CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); |
| - if (pList == NULL) { |
| - if (m_pPageResources == NULL) { |
| - return; |
| - } |
| - CPDF_Dictionary* pList = m_pPageResources->GetDict(FX_BSTRC("XObject")); |
| - if (pList == NULL) { |
| - return; |
| - } |
| - pRes = pList->GetElement(name); |
| - if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { |
| - return; |
| - } |
| - } else { |
| - pRes = pList->GetElement(name); |
| - if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { |
| - return; |
| - } |
| - } |
| } |
| + pRes = pList->GetElement(name); |
|
Tom Sepez
2015/10/22 21:49:13
nit: maybe
CPDF_Reference* pRes = ToReference(
dsinclair
2015/10/26 13:55:44
Done.
|
| + if (!ToReference(pRes)) |
| + return; |
| + |
|
Tom Sepez
2015/10/22 21:49:14
And I think the whole thing reduces down to this (
dsinclair
2015/10/26 13:55:44
Done.
|
| FX_BOOL bForm; |
| - if (m_pDocument->IsFormStream(((CPDF_Reference*)pRes)->GetRefObjNum(), |
| - bForm) && |
| - !bForm) { |
| + if (m_pDocument->IsFormStream(pRes->AsReference()->GetRefObjNum(), bForm) && |
|
Tom Sepez
2015/10/22 21:49:14
nit: then you can lose the redundant AsReference h
dsinclair
2015/10/26 13:55:44
Done.
|
| + !bForm) |
| return; |
| - } |
| } |
| + |
| CPDF_Stream* pXObject = ToStream(FindResourceObj(FX_BSTRC("XObject"), name)); |
| if (!pXObject) { |
| m_bResourceMissing = TRUE; |