Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp

Issue 1306793002: Fix infinite loop for objects that reference themselves. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index 592a7b13265dc3fb403734af9ca9db9ae0d84823..3cb849425ff56f6a437734a734e52e40a4660df6 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -134,6 +134,7 @@ int CPDF_Object::GetInteger() const {
}
return 0;
}
+
CPDF_Dictionary* CPDF_Object::GetDict() const {
switch (m_Type) {
case PDFOBJ_DICTIONARY:
@@ -142,19 +143,19 @@ CPDF_Dictionary* CPDF_Object::GetDict() const {
return ((CPDF_Stream*)this)->GetDict();
case PDFOBJ_REFERENCE: {
CPDF_Reference* pRef = (CPDF_Reference*)this;
- if (pRef->m_pObjList == NULL) {
- break;
- }
- CPDF_Object* pObj =
- pRef->m_pObjList->GetIndirectObject(pRef->m_RefObjNum);
- if (pObj == NULL) {
- return NULL;
- }
+ CPDF_IndirectObjects* pIndirect = pRef->GetObjList();
+ if (!pIndirect)
+ return nullptr;
+ CPDF_Object* pObj = pIndirect->GetIndirectObject(pRef->m_RefObjNum);
jun_fang 2015/08/21 21:44:43 nit: call pRef->GetRefObjNum to get object number
Lei Zhang 2015/08/31 05:45:02 Done. I made the same change everywhere in the fil
+ if (!pObj || (pObj == this))
+ return nullptr;
return pObj->GetDict();
}
+ default:
+ return nullptr;
}
- return NULL;
}
+
CPDF_Array* CPDF_Object::GetArray() const {
if (m_Type == PDFOBJ_ARRAY)
return (CPDF_Array*)this;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698