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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_array.cpp

Issue 1888333002: Prevent cloned arrays/dictionaries from having nullptrs. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 8 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 | core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
(...skipping 28 matching lines...) Expand all
39 return this; 39 return this;
40 } 40 }
41 41
42 const CPDF_Array* CPDF_Array::AsArray() const { 42 const CPDF_Array* CPDF_Array::AsArray() const {
43 return this; 43 return this;
44 } 44 }
45 45
46 CPDF_Object* CPDF_Array::Clone(FX_BOOL bDirect) const { 46 CPDF_Object* CPDF_Array::Clone(FX_BOOL bDirect) const {
47 CPDF_Array* pCopy = new CPDF_Array(); 47 CPDF_Array* pCopy = new CPDF_Array();
48 for (size_t i = 0; i < GetCount(); i++) { 48 for (size_t i = 0; i < GetCount(); i++) {
49 CPDF_Object* value = m_Objects.at(i); 49 CPDF_Object* pObj = m_Objects.at(i);
50 pCopy->m_Objects.push_back(value->Clone(bDirect)); 50 CPDF_Object* pCloneObj = pObj->Clone(bDirect);
51 if (pCloneObj)
52 pCopy->m_Objects.push_back(pCloneObj);
51 } 53 }
52 return pCopy; 54 return pCopy;
53 } 55 }
54 56
55 CFX_FloatRect CPDF_Array::GetRect() { 57 CFX_FloatRect CPDF_Array::GetRect() {
56 CFX_FloatRect rect; 58 CFX_FloatRect rect;
57 if (!IsArray() || m_Objects.size() != 4) 59 if (!IsArray() || m_Objects.size() != 4)
58 return rect; 60 return rect;
59 61
60 rect.left = GetNumberAt(0); 62 rect.left = GetNumberAt(0);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 ASSERT(IsArray()); 199 ASSERT(IsArray());
198 CPDF_Number* pNumber = new CPDF_Number(f); 200 CPDF_Number* pNumber = new CPDF_Number(f);
199 Add(pNumber); 201 Add(pNumber);
200 } 202 }
201 203
202 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc, 204 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc,
203 uint32_t objnum) { 205 uint32_t objnum) {
204 ASSERT(IsArray()); 206 ASSERT(IsArray());
205 Add(new CPDF_Reference(pDoc, objnum)); 207 Add(new CPDF_Reference(pDoc, objnum));
206 } 208 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698