Change CPDF_Stream::GetInMemoryRawData() to return a span.

Return a span, considering 2 out of the 3 callers want a span anyway.

Change-Id: Ia6c9ec30d6b44b03aa7b3098ff2127d27825cadd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/99511
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp
index 763f5e0..729a71f 100644
--- a/core/fpdfapi/parser/cpdf_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_stream.cpp
@@ -211,7 +211,7 @@
   return archive->WriteString("\r\nendstream");
 }
 
-const uint8_t* CPDF_Stream::GetInMemoryRawData() const {
+pdfium::span<const uint8_t> CPDF_Stream::GetInMemoryRawData() const {
   DCHECK(IsMemoryBased());
-  return m_pDataBuf.get();
+  return pdfium::make_span(m_pDataBuf.get(), GetRawSize());
 }
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h
index 53f694d..68e4311 100644
--- a/core/fpdfapi/parser/cpdf_stream.h
+++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -38,7 +38,7 @@
   // Can only be called when stream is memory-based.
   // This is meant to be used by CPDF_StreamAcc only.
   // Other callers should use CPDF_StreamAcc to access data in all cases.
-  const uint8_t* GetInMemoryRawData() const;
+  pdfium::span<const uint8_t> GetInMemoryRawData() const;
 
   // Copies span or stream into internally-owned buffer.
   void SetData(pdfium::span<const uint8_t> pData);
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp
index e7eb6f4..b9a5ab2 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.cpp
+++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp
@@ -83,7 +83,7 @@
   if (is_owned())
     return absl::get<OwnedData>(m_Data).buffer.get();
   return (m_pStream && m_pStream->IsMemoryBased())
-             ? m_pStream->GetInMemoryRawData()
+             ? m_pStream->GetInMemoryRawData().data()
              : nullptr;
 }
 
@@ -127,7 +127,7 @@
     return;
 
   if (m_pStream->IsMemoryBased()) {
-    m_Data = pdfium::make_span(m_pStream->GetInMemoryRawData(), dwSrcSize);
+    m_Data = m_pStream->GetInMemoryRawData();
     return;
   }
 
@@ -147,7 +147,7 @@
   absl::variant<pdfium::span<const uint8_t>, OwnedData> src_data;
   pdfium::span<const uint8_t> src_span;
   if (m_pStream->IsMemoryBased()) {
-    src_span = pdfium::make_span(m_pStream->GetInMemoryRawData(), dwSrcSize);
+    src_span = m_pStream->GetInMemoryRawData();
     src_data = src_span;
   } else {
     std::unique_ptr<uint8_t, FxFreeDeleter> pTempSrcData = ReadRawStream();