diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-04-17 17:19:30 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-17 17:19:30 +0000 |
commit | 1dbfe996b946f0d2a1afc52669ff5fca22a85070 (patch) | |
tree | f4037b8c4c46725a9c73276f9c58cd78883b79dc /core/fpdfapi/page/cpdf_image.cpp | |
parent | 2617056df6d6e1d0f17031f0c9db09f9192cb0fa (diff) | |
download | pdfium-1dbfe996b946f0d2a1afc52669ff5fca22a85070.tar.xz |
Re-land "Return pdfium::span<char> from ByteString::GetBuffer().""
This reverts commit 3d523e3cf89440e2ffc6571b1c687ad5e3f0318f.
Fixes bounding errors now caught by tests.
Change-Id: I4d0f1791bdcc45a10615a62abf7a4d20e7e538f2
Reviewed-on: https://pdfium-review.googlesource.com/30799
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_image.cpp')
-rw-r--r-- | core/fpdfapi/page/cpdf_image.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index 68a6a3243c..9ce4268a36 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -202,13 +202,16 @@ void CPDF_Image::SetImage(const RetainPtr<CFX_DIBitmap>& pBitmap) { pCS->AddNew<CPDF_Name>("DeviceRGB"); pCS->AddNew<CPDF_Number>(1); ByteString ct; - char* pBuf = ct.GetBuffer(6); - pBuf[0] = (char)reset_r; - pBuf[1] = (char)reset_g; - pBuf[2] = (char)reset_b; - pBuf[3] = (char)set_r; - pBuf[4] = (char)set_g; - pBuf[5] = (char)set_b; + { + // Span's lifetime must end before ReleaseBuffer() below. + pdfium::span<char> pBuf = ct.GetBuffer(6); + pBuf[0] = (char)reset_r; + pBuf[1] = (char)reset_g; + pBuf[2] = (char)reset_b; + pBuf[3] = (char)set_r; + pBuf[4] = (char)set_g; + pBuf[5] = (char)set_b; + } ct.ReleaseBuffer(6); pCS->AddNew<CPDF_String>(ct, true); } |