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/include/fpdfapi/fpdf_objects.h

Issue 1582963003: Fix some iterator invalidation issues while traversing CPDF_Dictionary. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix a bug in CPDF_Dictionary::ReplaceKey while we're at it Created 4 years, 11 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 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 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_
8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ 8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_
9 9
10 #include <map> 10 #include <map>
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 CPDF_Array* GetArray(const CFX_ByteStringC& key) const; 378 CPDF_Array* GetArray(const CFX_ByteStringC& key) const;
379 379
380 CFX_FloatRect GetRect(const CFX_ByteStringC& key) const; 380 CFX_FloatRect GetRect(const CFX_ByteStringC& key) const;
381 381
382 CFX_Matrix GetMatrix(const CFX_ByteStringC& key) const; 382 CFX_Matrix GetMatrix(const CFX_ByteStringC& key) const;
383 383
384 FX_FLOAT GetFloat(const CFX_ByteStringC& key) const { return GetNumber(key); } 384 FX_FLOAT GetFloat(const CFX_ByteStringC& key) const { return GetNumber(key); }
385 385
386 FX_BOOL KeyExist(const CFX_ByteStringC& key) const; 386 FX_BOOL KeyExist(const CFX_ByteStringC& key) const;
387 387
388 // Set* functions invalidates iterators for the given key.
Lei Zhang 2016/01/14 01:32:29 -> Set* functions invalidates iterators for |key|.
Oliver Chang 2016/01/14 02:04:53 oops, I completely missed this comment, and made m
388 void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj); 389 void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj);
389 390
390 void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name); 391 void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name);
391 392
392 void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& string); 393 void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& string);
393 394
394 void SetAtInteger(const CFX_ByteStringC& key, int i); 395 void SetAtInteger(const CFX_ByteStringC& key, int i);
395 396
396 void SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f); 397 void SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f);
397 398
(...skipping 10 matching lines...) Expand all
408 void AddReference(const CFX_ByteStringC& key, 409 void AddReference(const CFX_ByteStringC& key,
409 CPDF_IndirectObjectHolder* pDoc, 410 CPDF_IndirectObjectHolder* pDoc,
410 FX_DWORD objnum); 411 FX_DWORD objnum);
411 412
412 void SetAtRect(const CFX_ByteStringC& key, const CFX_FloatRect& rect); 413 void SetAtRect(const CFX_ByteStringC& key, const CFX_FloatRect& rect);
413 414
414 void SetAtMatrix(const CFX_ByteStringC& key, const CFX_Matrix& matrix); 415 void SetAtMatrix(const CFX_ByteStringC& key, const CFX_Matrix& matrix);
415 416
416 void SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue); 417 void SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue);
417 418
419 // Invalidates iterators for the given key.
418 void RemoveAt(const CFX_ByteStringC& key); 420 void RemoveAt(const CFX_ByteStringC& key);
419 421
422 // Invalidates iterators for oldkey.
420 void ReplaceKey(const CFX_ByteStringC& oldkey, const CFX_ByteStringC& newkey); 423 void ReplaceKey(const CFX_ByteStringC& oldkey, const CFX_ByteStringC& newkey);
421 424
422 FX_BOOL Identical(CPDF_Dictionary* pDict) const; 425 FX_BOOL Identical(CPDF_Dictionary* pDict) const;
423 426
424 size_t GetCount() const { return m_Map.size(); } 427 size_t GetCount() const { return m_Map.size(); }
425 428
426 iterator begin() { return m_Map.begin(); } 429 iterator begin() { return m_Map.begin(); }
427 430
428 iterator end() { return m_Map.end(); } 431 iterator end() { return m_Map.end(); }
429 432
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 iterator end() { return m_IndirectObjs.end(); } 599 iterator end() { return m_IndirectObjs.end(); }
597 const_iterator end() const { return m_IndirectObjs.end(); } 600 const_iterator end() const { return m_IndirectObjs.end(); }
598 601
599 protected: 602 protected:
600 CPDF_Parser* m_pParser; 603 CPDF_Parser* m_pParser;
601 FX_DWORD m_LastObjNum; 604 FX_DWORD m_LastObjNum;
602 std::map<FX_DWORD, CPDF_Object*> m_IndirectObjs; 605 std::map<FX_DWORD, CPDF_Object*> m_IndirectObjs;
603 }; 606 };
604 607
605 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ 608 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698