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

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

Issue 2273293003: Check for nullptrs in CPDF_Dictionary dtor. (Closed)
Patch Set: nit Created 4 years, 3 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
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 <set>
10 #include <utility>
11
9 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" 12 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
16 #include "third_party/base/stl_util.h" 19 #include "third_party/base/stl_util.h"
17 20
18 CPDF_Dictionary::CPDF_Dictionary() {} 21 CPDF_Dictionary::CPDF_Dictionary() {}
19 22
20 CPDF_Dictionary::~CPDF_Dictionary() { 23 CPDF_Dictionary::~CPDF_Dictionary() {
24 // Mark the object as deleted so that it will not be deleted again
25 // in case of cyclic references.
21 m_ObjNum = kInvalidObjNum; 26 m_ObjNum = kInvalidObjNum;
22 for (const auto& it : m_Map) 27 for (const auto& it : m_Map) {
23 it.second->Release(); 28 if (it.second)
29 it.second->Release();
30 }
24 } 31 }
25 32
26 CPDF_Object::Type CPDF_Dictionary::GetType() const { 33 CPDF_Object::Type CPDF_Dictionary::GetType() const {
27 return DICTIONARY; 34 return DICTIONARY;
28 } 35 }
29 36
30 CPDF_Dictionary* CPDF_Dictionary::GetDict() const { 37 CPDF_Dictionary* CPDF_Dictionary::GetDict() const {
31 // The method should be made non-const if we want to not be const. 38 // The method should be made non-const if we want to not be const.
32 // See bug #234. 39 // See bug #234.
33 return const_cast<CPDF_Dictionary*>(this); 40 return const_cast<CPDF_Dictionary*>(this);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 const CFX_Matrix& matrix) { 256 const CFX_Matrix& matrix) {
250 CPDF_Array* pArray = new CPDF_Array; 257 CPDF_Array* pArray = new CPDF_Array;
251 pArray->AddNumber(matrix.a); 258 pArray->AddNumber(matrix.a);
252 pArray->AddNumber(matrix.b); 259 pArray->AddNumber(matrix.b);
253 pArray->AddNumber(matrix.c); 260 pArray->AddNumber(matrix.c);
254 pArray->AddNumber(matrix.d); 261 pArray->AddNumber(matrix.d);
255 pArray->AddNumber(matrix.e); 262 pArray->AddNumber(matrix.e);
256 pArray->AddNumber(matrix.f); 263 pArray->AddNumber(matrix.f);
257 SetAt(key, pArray); 264 SetAt(key, pArray);
258 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698