summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/page/cpdf_image.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index ec826dc5ed..b10134611c 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -200,13 +200,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);
}