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

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

Issue 2375343004: Assert that only 0-numbered objects are Released() (Closed)
Patch Set: brute-force delete unowned numbered object in one place Created 4 years, 2 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/cpdf_dictionary.h" 7 #include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h"
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 11
12 #include "core/fpdfapi/fpdf_parser/cpdf_array.h" 12 #include "core/fpdfapi/fpdf_parser/cpdf_array.h"
13 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" 13 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
14 #include "core/fpdfapi/fpdf_parser/cpdf_name.h" 14 #include "core/fpdfapi/fpdf_parser/cpdf_name.h"
15 #include "core/fpdfapi/fpdf_parser/cpdf_number.h" 15 #include "core/fpdfapi/fpdf_parser/cpdf_number.h"
16 #include "core/fpdfapi/fpdf_parser/cpdf_reference.h" 16 #include "core/fpdfapi/fpdf_parser/cpdf_reference.h"
17 #include "core/fpdfapi/fpdf_parser/cpdf_stream.h" 17 #include "core/fpdfapi/fpdf_parser/cpdf_stream.h"
18 #include "core/fpdfapi/fpdf_parser/cpdf_string.h" 18 #include "core/fpdfapi/fpdf_parser/cpdf_string.h"
19 #include "third_party/base/logging.h" 19 #include "third_party/base/logging.h"
20 #include "third_party/base/stl_util.h" 20 #include "third_party/base/stl_util.h"
21 21
22 CPDF_Dictionary::CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool) 22 CPDF_Dictionary::CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
23 : m_pPool(pPool) {} 23 : m_pPool(pPool) {}
24 24
25 CPDF_Dictionary::~CPDF_Dictionary() { 25 CPDF_Dictionary::~CPDF_Dictionary() {
26 // Mark the object as deleted so that it will not be deleted again 26 // Mark the object as deleted so that it will not be deleted again
27 // in case of cyclic references. 27 // in case of cyclic references.
28 m_ObjNum = kInvalidObjNum; 28 m_ObjNum = kInvalidObjNum;
29 for (const auto& it : m_Map) { 29 for (const auto& it : m_Map) {
30 if (it.second) 30 if (it.second && it.second->GetObjNum() != kInvalidObjNum)
31 it.second->Release(); 31 it.second->Release();
32 } 32 }
33 } 33 }
34 34
35 CPDF_Object::Type CPDF_Dictionary::GetType() const { 35 CPDF_Object::Type CPDF_Dictionary::GetType() const {
36 return DICTIONARY; 36 return DICTIONARY;
37 } 37 }
38 38
39 CPDF_Dictionary* CPDF_Dictionary::GetDict() const { 39 CPDF_Dictionary* CPDF_Dictionary::GetDict() const {
40 // The method should be made non-const if we want to not be const. 40 // The method should be made non-const if we want to not be const.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 pArray->AddNumber(matrix.c); 263 pArray->AddNumber(matrix.c);
264 pArray->AddNumber(matrix.d); 264 pArray->AddNumber(matrix.d);
265 pArray->AddNumber(matrix.e); 265 pArray->AddNumber(matrix.e);
266 pArray->AddNumber(matrix.f); 266 pArray->AddNumber(matrix.f);
267 SetFor(key, pArray); 267 SetFor(key, pArray);
268 } 268 }
269 269
270 CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) { 270 CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) {
271 return m_pPool ? m_pPool->Intern(str) : str; 271 return m_pPool ? m_pPool->Intern(str) : str;
272 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698