summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/fx_codec_icc.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2018-05-28 20:06:19 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-28 20:06:19 +0000
commitac8357b3ec7e1fe4000ebcae5ce65a38bfeb5cb1 (patch)
tree3ba35d4111e491cf6f81eb5fe386d53001d8227e /core/fxcodec/codec/fx_codec_icc.cpp
parentfffdeebfd0ed9806d32eb5609e0fdd015c25c5ac (diff)
downloadpdfium-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/fxcodec/codec/fx_codec_icc.cpp')
-rw-r--r--core/fxcodec/codec/fx_codec_icc.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp
index 458816e77e..29b37d19ac 100644
--- a/core/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/fxcodec/codec/fx_codec_icc.cpp
@@ -5,10 +5,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include <memory>
-#include <vector>
#include "core/fxcodec/codec/ccodec_iccmodule.h"
#include "core/fxcodec/codec/codec_int.h"
+#include "core/fxcrt/cfx_fixedbufgrow.h"
namespace {
@@ -124,16 +124,19 @@ void CCodec_IccModule::Translate(CLcmsCmm* pTransform,
uint32_t nSrcComponents = m_nComponents;
uint8_t output[4];
if (pTransform->m_bLab) {
- std::vector<double> input(pSrcValues, pSrcValues + nSrcComponents);
- cmsDoTransform(pTransform->m_hTransform, input.data(), output, 1);
+ CFX_FixedBufGrow<double, 16> inputs(nSrcComponents);
+ double* input = inputs;
+ for (uint32_t i = 0; i < nSrcComponents; ++i)
+ input[i] = pSrcValues[i];
+ cmsDoTransform(pTransform->m_hTransform, input, output, 1);
} else {
- std::vector<uint8_t> input;
- input.reserve(nSrcComponents);
+ CFX_FixedBufGrow<uint8_t, 16> inputs(nSrcComponents);
+ uint8_t* input = inputs;
for (uint32_t i = 0; i < nSrcComponents; ++i) {
- input.push_back(
- pdfium::clamp(static_cast<int>(pSrcValues[i] * 255.0f), 0, 255));
+ input[i] =
+ pdfium::clamp(static_cast<int>(pSrcValues[i] * 255.0f), 0, 255);
}
- cmsDoTransform(pTransform->m_hTransform, input.data(), output, 1);
+ cmsDoTransform(pTransform->m_hTransform, input, output, 1);
}
pDestValues[0] = output[2] / 255.0f;
pDestValues[1] = output[1] / 255.0f;