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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_dictionary.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 | « core/fpdfapi/fpdf_parser/cpdf_array.cpp ('k') | 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 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_dictionary.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" 9 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
(...skipping 28 matching lines...) Expand all
39 CPDF_Dictionary* CPDF_Dictionary::AsDictionary() { 39 CPDF_Dictionary* CPDF_Dictionary::AsDictionary() {
40 return this; 40 return this;
41 } 41 }
42 42
43 const CPDF_Dictionary* CPDF_Dictionary::AsDictionary() const { 43 const CPDF_Dictionary* CPDF_Dictionary::AsDictionary() const {
44 return this; 44 return this;
45 } 45 }
46 46
47 CPDF_Object* CPDF_Dictionary::Clone(FX_BOOL bDirect) const { 47 CPDF_Object* CPDF_Dictionary::Clone(FX_BOOL bDirect) const {
48 CPDF_Dictionary* pCopy = new CPDF_Dictionary(); 48 CPDF_Dictionary* pCopy = new CPDF_Dictionary();
49 for (const auto& it : *this) 49 for (const auto& it : *this) {
50 pCopy->m_Map.insert(std::make_pair(it.first, it.second->Clone(bDirect))); 50 CPDF_Object* pClonedObj = it.second->Clone(bDirect);
51 if (pClonedObj)
52 pCopy->m_Map.insert(std::make_pair(it.first, pClonedObj));
53 }
51 return pCopy; 54 return pCopy;
52 } 55 }
53 56
54 CPDF_Object* CPDF_Dictionary::GetObjectBy(const CFX_ByteString& key) const { 57 CPDF_Object* CPDF_Dictionary::GetObjectBy(const CFX_ByteString& key) const {
55 auto it = m_Map.find(key); 58 auto it = m_Map.find(key);
56 return it != m_Map.end() ? it->second : nullptr; 59 return it != m_Map.end() ? it->second : nullptr;
57 } 60 }
58 61
59 CPDF_Object* CPDF_Dictionary::GetDirectObjectBy( 62 CPDF_Object* CPDF_Dictionary::GetDirectObjectBy(
60 const CFX_ByteString& key) const { 63 const CFX_ByteString& key) const {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 const CFX_Matrix& matrix) { 245 const CFX_Matrix& matrix) {
243 CPDF_Array* pArray = new CPDF_Array; 246 CPDF_Array* pArray = new CPDF_Array;
244 pArray->AddNumber(matrix.a); 247 pArray->AddNumber(matrix.a);
245 pArray->AddNumber(matrix.b); 248 pArray->AddNumber(matrix.b);
246 pArray->AddNumber(matrix.c); 249 pArray->AddNumber(matrix.c);
247 pArray->AddNumber(matrix.d); 250 pArray->AddNumber(matrix.d);
248 pArray->AddNumber(matrix.e); 251 pArray->AddNumber(matrix.e);
249 pArray->AddNumber(matrix.f); 252 pArray->AddNumber(matrix.f);
250 SetAt(key, pArray); 253 SetAt(key, pArray);
251 } 254 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_array.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698