summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-09-04 19:59:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-04 19:59:03 +0000
commit76188c505dac5c4e35911edbc97d0dacbe366038 (patch)
tree91b8413cbf748a38b39f391472b77d201ecc8f39 /core/fpdfapi/page
parent73e97f4fac2f4f591ff62e70377a80fd40b5f6f3 (diff)
downloadpdfium-76188c505dac5c4e35911edbc97d0dacbe366038.tar.xz
Fix some more span/memcpy interactions.
Use the preferred idiom of creating a subspan, which makes the proper checks prior to the copy. Change-Id: Ia7f25b5760dea5707df66cf421195b23a1ce0ad0 Reviewed-on: https://pdfium-review.googlesource.com/41911 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index 0d45ed0323..9533bb2a17 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -177,7 +177,8 @@ std::unique_ptr<CPDF_Stream> CPDF_StreamParser::ReadInlineStream(
if (OrigSize > m_pBuf.size() - m_Pos)
OrigSize = m_pBuf.size() - m_Pos;
pData.reset(FX_Alloc(uint8_t, OrigSize));
- memcpy(pData.get(), &m_pBuf[m_Pos], OrigSize);
+ auto copy_span = m_pBuf.subspan(m_Pos, OrigSize);
+ memcpy(pData.get(), copy_span.data(), copy_span.size());
dwStreamSize = OrigSize;
m_Pos += OrigSize;
} else {
@@ -209,7 +210,8 @@ std::unique_ptr<CPDF_Stream> CPDF_StreamParser::ReadInlineStream(
}
m_Pos = dwSavePos;
pData.reset(FX_Alloc(uint8_t, dwStreamSize));
- memcpy(pData.get(), &m_pBuf[m_Pos], dwStreamSize);
+ auto copy_span = m_pBuf.subspan(m_Pos, dwStreamSize);
+ memcpy(pData.get(), copy_span.data(), copy_span.size());
m_Pos += dwStreamSize;
}
pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(dwStreamSize));