summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_parser.h
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-06-28 14:39:28 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-28 19:29:38 +0000
commitd4fb57a4e23ccc2e374c64ea5d5705f492fdd083 (patch)
tree382bf1ccdef3701280407a3b266f90706b0e39ed /core/fpdfapi/parser/cpdf_parser.h
parent67476e5ef6f122f39f547f5a14b84e9306fa136c (diff)
downloadpdfium-d4fb57a4e23ccc2e374c64ea5d5705f492fdd083.tar.xz
Keep all trailers in CPDF_Parser in m_Trailers
This CL removes m_pTrailer in favor of having them all in a vector, and having an index that points to the position of the previous m_pTrailer in the vector. Bug: pdfium:787 Change-Id: Ieebbf4849f7ea78f8f74d188e3adb3446a53482e Reviewed-on: https://pdfium-review.googlesource.com/7040 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.h')
-rw-r--r--core/fpdfapi/parser/cpdf_parser.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index 8f55ddb325..efe10555f7 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -7,6 +7,7 @@
#ifndef CORE_FPDFAPI_PARSER_CPDF_PARSER_H_
#define CORE_FPDFAPI_PARSER_CPDF_PARSER_H_
+#include <limits>
#include <map>
#include <memory>
#include <set>
@@ -41,6 +42,8 @@ class CPDF_Parser {
// are higher, but this may be large enough in practice.
static const uint32_t kMaxObjectNumber = 1048576;
+ static const size_t kInvalidPos = std::numeric_limits<size_t>::max();
+
CPDF_Parser();
~CPDF_Parser();
@@ -51,7 +54,10 @@ class CPDF_Parser {
void SetPassword(const char* password) { m_Password = password; }
CFX_ByteString GetPassword() { return m_Password; }
- CPDF_Dictionary* GetTrailer() const { return m_pTrailer.get(); }
+ CPDF_Dictionary* GetTrailer() const {
+ return m_TrailerPos == kInvalidPos ? nullptr
+ : m_Trailers[m_TrailerPos].get();
+ }
FX_FILESIZE GetLastXRefOffset() const { return m_LastXRefOffset; }
uint32_t GetPermissions() const;
@@ -161,8 +167,8 @@ class CPDF_Parser {
std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler;
CFX_ByteString m_Password;
std::set<FX_FILESIZE> m_SortedOffset;
- std::unique_ptr<CPDF_Dictionary> m_pTrailer;
std::vector<std::unique_ptr<CPDF_Dictionary>> m_Trailers;
+ size_t m_TrailerPos;
std::unique_ptr<CPDF_LinearizedHeader> m_pLinearized;
uint32_t m_dwXrefStartObjNum;