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

Unified Diff: core/include/fpdfapi/fpdf_parser.h

Issue 1569343002: Fix infinite loop caused by parsing same indirect objects (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/include/fpdfapi/fpdf_parser.h
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index 756850932e5573fcb1f43704fe4cc3364a365db9..bb6b8ac58eb2ce0518d3d3afd9ad86a7245e8980 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -9,6 +9,7 @@
#include <map>
#include <memory>
+#include <set>
#include "core/include/fpdfapi/fpdf_objects.h"
#include "core/include/fxcrt/fx_system.h"
@@ -364,6 +365,21 @@ struct PARSE_CONTEXT {
#define PDFPARSE_ERROR_HANDLER 4
#define PDFPARSE_ERROR_CERT 5
+template <typename T>
+class ScopedSetInsertion {
Lei Zhang 2016/01/08 20:27:07 Move this to fpdf_parser_parser.cpp's anonymous na
Wei Li 2016/01/08 22:01:50 Done.
+ public:
+ ScopedSetInsertion(std::set<T>* org_set, T elem) {
+ org_set->insert(elem);
+ set = org_set;
Lei Zhang 2016/01/08 20:27:07 Put these in the initializer list instead?
Wei Li 2016/01/08 22:01:50 Done.
+ entry = elem;
+ }
+ ~ScopedSetInsertion() { set->erase(entry); }
+
+ private:
+ std::set<T>* set;
Lei Zhang 2016/01/08 20:27:07 std::set<T>* const m_set;
Lei Zhang 2016/01/08 20:27:07 m_set / m_entry
Wei Li 2016/01/08 22:01:50 Done.
Wei Li 2016/01/08 22:01:50 Done.
+ T entry;
+};
+
class CPDF_Parser {
public:
CPDF_Parser();
@@ -536,6 +552,9 @@ class CPDF_Parser {
// streams in |m_ObjectStreamMap| are valid.
std::map<CPDF_StreamAcc*, StreamObjectCache> m_ObjCache;
+ // All indirect object numbers that are being parsed.
+ std::set<FX_DWORD> objnums_in_processing;
Lei Zhang 2016/01/08 20:27:07 Also m_SomeThing.
Wei Li 2016/01/08 22:01:50 Done.
+
friend class CPDF_Creator;
friend class CPDF_DataAvail;
};
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698