diff options
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); } |