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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fpdfapi/fpdf_parser.h" 7 #include "../../../include/fpdfapi/fpdf_parser.h"
8 #include "../../../include/fxcrt/fx_string.h" 8 #include "../../../include/fxcrt/fx_string.h"
9 9
10 // static 10 // static
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 CPDF_Object* pObj = 127 CPDF_Object* pObj =
128 pRef->m_pObjList->GetIndirectObject(pRef->m_RefObjNum, &context); 128 pRef->m_pObjList->GetIndirectObject(pRef->m_RefObjNum, &context);
129 if (pObj == NULL) { 129 if (pObj == NULL) {
130 return 0; 130 return 0;
131 } 131 }
132 return pObj->GetInteger(); 132 return pObj->GetInteger();
133 } 133 }
134 } 134 }
135 return 0; 135 return 0;
136 } 136 }
137
137 CPDF_Dictionary* CPDF_Object::GetDict() const { 138 CPDF_Dictionary* CPDF_Object::GetDict() const {
138 switch (m_Type) { 139 switch (m_Type) {
139 case PDFOBJ_DICTIONARY: 140 case PDFOBJ_DICTIONARY:
140 return (CPDF_Dictionary*)this; 141 return (CPDF_Dictionary*)this;
141 case PDFOBJ_STREAM: 142 case PDFOBJ_STREAM:
142 return ((CPDF_Stream*)this)->GetDict(); 143 return ((CPDF_Stream*)this)->GetDict();
143 case PDFOBJ_REFERENCE: { 144 case PDFOBJ_REFERENCE: {
144 CPDF_Reference* pRef = (CPDF_Reference*)this; 145 CPDF_Reference* pRef = (CPDF_Reference*)this;
145 if (pRef->m_pObjList == NULL) { 146 CPDF_IndirectObjects* pIndirect = pRef->GetObjList();
146 break; 147 if (!pIndirect)
147 } 148 return nullptr;
148 CPDF_Object* pObj = 149 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
149 pRef->m_pObjList->GetIndirectObject(pRef->m_RefObjNum); 150 if (!pObj || (pObj == this))
150 if (pObj == NULL) { 151 return nullptr;
151 return NULL;
152 }
153 return pObj->GetDict(); 152 return pObj->GetDict();
154 } 153 }
154 default:
155 return nullptr;
155 } 156 }
156 return NULL;
157 } 157 }
158
158 CPDF_Array* CPDF_Object::GetArray() const { 159 CPDF_Array* CPDF_Object::GetArray() const {
159 if (m_Type == PDFOBJ_ARRAY) 160 if (m_Type == PDFOBJ_ARRAY)
160 return (CPDF_Array*)this; 161 return (CPDF_Array*)this;
161 162
162 return NULL; 163 return NULL;
163 } 164 }
164 void CPDF_Object::SetString(const CFX_ByteString& str) { 165 void CPDF_Object::SetString(const CFX_ByteString& str) {
165 ASSERT(this != NULL); 166 ASSERT(this != NULL);
166 switch (m_Type) { 167 switch (m_Type) {
167 case PDFOBJ_BOOLEAN: 168 case PDFOBJ_BOOLEAN:
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 } 1198 }
1198 pObj->m_ObjNum = objnum; 1199 pObj->m_ObjNum = objnum;
1199 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); 1200 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj);
1200 if (m_LastObjNum < objnum) { 1201 if (m_LastObjNum < objnum) {
1201 m_LastObjNum = objnum; 1202 m_LastObjNum = objnum;
1202 } 1203 }
1203 } 1204 }
1204 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { 1205 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const {
1205 return m_LastObjNum; 1206 return m_LastObjNum;
1206 } 1207 }
OLDNEW
« 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