diff options
author | tsepez <tsepez@chromium.org> | 2016-11-04 11:02:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-04 11:02:59 -0700 |
commit | 761eed284e1248f851fbb23beaa45835b644ecee (patch) | |
tree | 34cff2bb264236174957fb0b7fc7a8c3c1f26e30 /core/fpdfapi/parser/cpdf_parser.cpp | |
parent | f0d5b6c35fa343108a3ab7a25bc2cc2b3cf105b3 (diff) | |
download | pdfium-761eed284e1248f851fbb23beaa45835b644ecee.tar.xz |
Assert objnum non-zero in ReplaceIndirectObjectIfHigherGeneration()
Removes a path where it might not have taken ownership of an object,
at the expense of making callers check first. This eases making
the second argument an unique_ptr someday.
Review-Url: https://codereview.chromium.org/2475823002
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index cff0f77b32..96e59fb62f 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -960,14 +960,16 @@ bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) { if (!pObject) return false; - CPDF_Object* pUnownedObject = pObject.get(); + uint32_t objnum = pObject->m_ObjNum; + if (!objnum) + return false; + CPDF_Object* pUnownedObject = pObject.get(); if (m_pDocument) { CPDF_Dictionary* pRootDict = m_pDocument->GetRoot(); - if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum) + if (pRootDict && pRootDict->GetObjNum() == objnum) return false; // Takes ownership of object (std::move someday). - uint32_t objnum = pObject->m_ObjNum; if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration( objnum, pObject.release())) { return false; |