diff options
author | Nicolas Pena <npm@chromium.org> | 2018-05-28 20:06:19 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-28 20:06:19 +0000 |
commit | ac8357b3ec7e1fe4000ebcae5ce65a38bfeb5cb1 (patch) | |
tree | 3ba35d4111e491cf6f81eb5fe386d53001d8227e /core/fpdfapi/render/cpdf_dibsource.cpp | |
parent | fffdeebfd0ed9806d32eb5609e0fdd015c25c5ac (diff) | |
download | pdfium-ac8357b3ec7e1fe4000ebcae5ce65a38bfeb5cb1.tar.xz |
Revert 'Remove almost all usages of CFX_FixedBufGrow with std::vector'chromium/3444
This is a manual revert of the CL at:
https://pdfium-review.googlesource.com/c/pdfium/+/32159
The only file manually changed was cpdf_renderstatus.cpp
Reason for revert: the bug below shows that sometimes the vector size
used is larger than the parameter given to CFX_FixedBufGrow. Thus, we
will revert, then add vectors using std::max unless it's clear from the
code that the code will never access indices outside.
Bug: chromium:847247
Change-Id: Iee54af023c8564824418a7d34a6385b0bc418ff0
Reviewed-on: https://pdfium-review.googlesource.com/33050
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/render/cpdf_dibsource.cpp')
-rw-r--r-- | core/fpdfapi/render/cpdf_dibsource.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp index ad828f2372..4241fb1b40 100644 --- a/core/fpdfapi/render/cpdf_dibsource.cpp +++ b/core/fpdfapi/render/cpdf_dibsource.cpp @@ -761,7 +761,8 @@ void CPDF_DIBSource::LoadPalette() { } int palette_count = 1 << (m_bpc * m_nComponents); - std::vector<float> color_value(m_nComponents); + CFX_FixedBufGrow<float, 16> color_values(m_nComponents); + float* color_value = color_values; for (int i = 0; i < palette_count; i++) { int color_data = i; for (uint32_t j = 0; j < m_nComponents; j++) { @@ -778,11 +779,11 @@ void CPDF_DIBSource::LoadPalette() { int nComponents = m_pColorSpace->CountComponents(); std::vector<float> temp_buf(nComponents); for (int k = 0; k < nComponents; k++) { - temp_buf[k] = color_value[0]; + temp_buf[k] = *color_value; } m_pColorSpace->GetRGB(temp_buf.data(), &R, &G, &B); } else { - m_pColorSpace->GetRGB(color_value.data(), &R, &G, &B); + m_pColorSpace->GetRGB(color_value, &R, &G, &B); } SetPaletteArgb(i, ArgbEncode(255, FXSYS_round(R * 255), FXSYS_round(G * 255), FXSYS_round(B * 255))); @@ -830,7 +831,8 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, if (TranslateScanline24bppDefaultDecode(dest_scan, src_scan)) return; - std::vector<float> color_values(m_nComponents); + CFX_FixedBufGrow<float, 16> color_values1(m_nComponents); + float* color_values = color_values1; float R = 0.0f; float G = 0.0f; float B = 0.0f; @@ -858,7 +860,7 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, G = (1.0f - color_values[1]) * k; B = (1.0f - color_values[2]) * k; } else if (m_Family != PDFCS_PATTERN) { - m_pColorSpace->GetRGB(color_values.data(), &R, &G, &B); + m_pColorSpace->GetRGB(color_values, &R, &G, &B); } R = pdfium::clamp(R, 0.0f, 1.0f); G = pdfium::clamp(G, 0.0f, 1.0f); |