summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-06-02 15:48:15 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-02 15:48:16 -0700
commitdb444d2063df6c574882d9263e885c4fe1134133 (patch)
tree27ce4a3f181ae0b5ad4eff6893016e7d49dfce0a /core/fpdfapi/fpdf_page
parentad700c2c1fc3c3843dae71e5982f462e42efc987 (diff)
downloadpdfium-db444d2063df6c574882d9263e885c4fe1134133.tar.xz
Fix all the code which has duplicate variable declarations
When there are duplicate variable declarations, the inner names shadow the outter ones. This is error prone and harder to read. Remove all the instances found by /analyze. BUG=chromium:613623, chromium:427616 Review-Url: https://codereview.chromium.org/2027273002
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser.cpp35
1 files changed, 10 insertions, 25 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 52576043e3..4bd4a4d529 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -1139,31 +1139,16 @@ void CPDF_StreamContentParser::Handle_SetFont() {
CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
const CFX_ByteString& type,
const CFX_ByteString& name) {
- if (!m_pResources) {
- return NULL;
- }
- if (m_pResources == m_pPageResources) {
- CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
- if (!pList) {
- return NULL;
- }
- CPDF_Object* pRes = pList->GetDirectObjectBy(name);
- return pRes;
- }
- CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
- if (!pList) {
- if (!m_pPageResources) {
- return NULL;
- }
- CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type);
- if (!pList) {
- return NULL;
- }
- CPDF_Object* pRes = pList->GetDirectObjectBy(name);
- return pRes;
- }
- CPDF_Object* pRes = pList->GetDirectObjectBy(name);
- return pRes;
+ if (!m_pResources)
+ return nullptr;
+ CPDF_Dictionary* pDict = m_pResources->GetDictBy(type);
+ if (pDict)
+ return pDict->GetDirectObjectBy(name);
+ if (m_pResources == m_pPageResources || !m_pPageResources)
+ return nullptr;
+
+ CPDF_Dictionary* pPageDict = m_pPageResources->GetDictBy(type);
+ return pPageDict ? pPageDict->GetDirectObjectBy(name) : nullptr;
}
CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {