summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_streamparser.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-06 23:48:24 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-06 23:48:24 +0000
commit6058efdbdc186e120e7e2121c290ac4d820ffbf8 (patch)
tree8944872de2d924d3efd76266cc929c6f25199134 /core/fpdfapi/page/cpdf_streamparser.h
parent2aa01f5ccbf1464b43527c1ffa6b42bafed9ebeb (diff)
downloadpdfium-6058efdbdc186e120e7e2121c290ac4d820ffbf8.tar.xz
Add span.h from chromium base.chromium/3392
Allows indexing with better bounds-checking to occur. Some small modifications are required to deal with PDFium being intentionally held at C++11 compliance, not C++14. Use in one place as check on correctness. Change-Id: Id2875cf0a93980112bc536a93c4f9ec5306c0dac Reviewed-on: https://pdfium-review.googlesource.com/29671 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Chris Palmer <palmer@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_streamparser.h')
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
index bdd07643ce..78727da481 100644
--- a/core/fpdfapi/page/cpdf_streamparser.h
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -16,14 +16,14 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fxcrt/string_pool_template.h"
#include "core/fxcrt/weak_ptr.h"
+#include "third_party/base/span.h"
class CPDF_StreamParser {
public:
enum SyntaxType { EndOfData, Number, Keyword, Name, Others };
- CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize);
- CPDF_StreamParser(const uint8_t* pData,
- uint32_t dwSize,
+ explicit CPDF_StreamParser(pdfium::span<const uint8_t> span);
+ CPDF_StreamParser(pdfium::span<const uint8_t> span,
const WeakPtr<ByteStringPool>& pPool);
~CPDF_StreamParser();
@@ -51,12 +51,11 @@ class CPDF_StreamParser {
ByteString ReadHexString();
bool PositionIsInBounds() const;
- uint32_t m_Size; // Length in bytes of m_pBuf.
- uint32_t m_Pos; // Current byte position within m_pBuf.
- uint32_t m_WordSize; // Current byte position within m_WordBuffer.
- const uint8_t* m_pBuf;
- std::unique_ptr<CPDF_Object> m_pLastObj;
+ uint32_t m_Pos = 0; // Current byte position within m_pBuf.
+ uint32_t m_WordSize = 0; // Current byte position within m_WordBuffer.
WeakPtr<ByteStringPool> m_pPool;
+ std::unique_ptr<CPDF_Object> m_pLastObj;
+ pdfium::span<const uint8_t> m_pBuf;
uint8_t m_WordBuffer[kMaxWordLength + 1]; // Include space for NUL.
};