From 53894390dba2ec571bab75157ebe60d11171ed07 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 9 Apr 2018 18:30:24 +0000 Subject: Use pdfium::span<> in CFX_BitStream, CPDF_SimpleParser. Get bounds checks in parsers automatically when using spans. Change-Id: I71fbe7b838435d455376db2f89817d807a9cdcfd Reviewed-on: https://pdfium-review.googlesource.com/29830 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_stream_acc.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'core/fpdfapi/parser/cpdf_stream_acc.h') diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h index ac5253a68b..89a454a0f0 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.h +++ b/core/fpdfapi/parser/cpdf_stream_acc.h @@ -14,6 +14,7 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" #include "core/fxcrt/retain_ptr.h" +#include "third_party/base/span.h" class CPDF_StreamAcc : public Retainable { public: @@ -30,11 +31,11 @@ class CPDF_StreamAcc : public Retainable { const CPDF_Stream* GetStream() const { return m_pStream.Get(); } CPDF_Dictionary* GetDict() const; - ByteStringView GetDataView() { return ByteStringView(GetData(), GetSize()); } - - const uint8_t* GetData() const; - uint8_t* GetData(); + uint8_t* GetData() const; uint32_t GetSize() const; + pdfium::span GetSpan() const { + return pdfium::make_span(GetData(), GetSize()); + } const ByteString& GetImageDecoder() const { return m_ImageDecoder; } const CPDF_Dictionary* GetImageParam() const { return m_pImageParam; } std::unique_ptr DetachData(); @@ -44,8 +45,6 @@ class CPDF_StreamAcc : public Retainable { ~CPDF_StreamAcc() override; private: - uint8_t* GetDataHelper() const; - uint8_t* m_pData = nullptr; uint32_t m_dwSize = 0; bool m_bNewBuf = false; -- cgit v1.2.3