Store uint8_t vector data in data partition in fxcodec/ Change-Id: I679de621189a0413436cb0c298a1ea308d893c1b Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/68253 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.h b/core/fxcodec/bmp/cfx_bmpdecompressor.h index 3f4e2d8..98429b3 100644 --- a/core/fxcodec/bmp/cfx_bmpdecompressor.h +++ b/core/fxcodec/bmp/cfx_bmpdecompressor.h
@@ -11,6 +11,7 @@ #include "core/fxcodec/bmp/bmpmodule.h" #include "core/fxcodec/bmp/fx_bmp.h" +#include "core/fxcrt/fx_memory_wrappers.h" #include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/unowned_ptr.h" @@ -65,7 +66,7 @@ bool SetHeight(int32_t signed_height); UnownedPtr<CFX_BmpContext> const context_; - std::vector<uint8_t> out_row_buffer_; + std::vector<uint8_t, FxAllocAllocator<uint8_t>> out_row_buffer_; std::vector<uint32_t> palette_; uint32_t header_offset_ = 0; uint32_t width_ = 0;
diff --git a/core/fxcodec/gif/cfx_gifcontext_unittest.cpp b/core/fxcodec/gif/cfx_gifcontext_unittest.cpp index 20d34ea..818e8b9 100644 --- a/core/fxcodec/gif/cfx_gifcontext_unittest.cpp +++ b/core/fxcodec/gif/cfx_gifcontext_unittest.cpp
@@ -47,7 +47,7 @@ } TEST(CFX_GifContext, ReadAllOrNone) { - std::vector<uint8_t> dest_buffer; + std::vector<uint8_t, FxAllocAllocator<uint8_t>> dest_buffer; uint8_t src_buffer[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}; CFX_GifContextForTest context(nullptr, nullptr);
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor.h b/core/fxcodec/gif/cfx_lzwdecompressor.h index d3ec588..60c9388 100644 --- a/core/fxcodec/gif/cfx_lzwdecompressor.h +++ b/core/fxcodec/gif/cfx_lzwdecompressor.h
@@ -34,7 +34,9 @@ return ExtractData(dest_buf, dest_size); } - std::vector<uint8_t>* DecompressedForTest() { return &decompressed_; } + std::vector<uint8_t, FxAllocAllocator<uint8_t>>* DecompressedForTest() { + return &decompressed_; + } size_t* DecompressedNextForTest() { return &decompressed_next_; } private: @@ -51,7 +53,7 @@ uint16_t code_end_; uint16_t code_next_; uint8_t code_first_; - std::vector<uint8_t> decompressed_; + std::vector<uint8_t, FxAllocAllocator<uint8_t>> decompressed_; size_t decompressed_next_; uint16_t code_old_; const uint8_t* next_in_;
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp b/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp index e31fb78..58cb086 100644 --- a/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp +++ b/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
@@ -21,7 +21,8 @@ // Check that 0 length extract does nothing { - std::vector<uint8_t>* decompressed = decompressor->DecompressedForTest(); + std::vector<uint8_t, FxAllocAllocator<uint8_t>>* decompressed = + decompressor->DecompressedForTest(); *decompressed = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; *(decompressor->DecompressedNextForTest()) = decompressed->size(); uint8_t dest_buf[20]; @@ -38,7 +39,8 @@ // Check that less than decompressed size only gets the expected number { - std::vector<uint8_t>* decompressed = decompressor->DecompressedForTest(); + std::vector<uint8_t, FxAllocAllocator<uint8_t>>* decompressed = + decompressor->DecompressedForTest(); *decompressed = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; *(decompressor->DecompressedNextForTest()) = decompressed->size(); uint8_t dest_buf[20]; @@ -58,7 +60,8 @@ // Check that greater than decompressed size depletes the decompressor { - std::vector<uint8_t>* decompressed = decompressor->DecompressedForTest(); + std::vector<uint8_t, FxAllocAllocator<uint8_t>>* decompressed = + decompressor->DecompressedForTest(); *decompressed = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; *(decompressor->DecompressedNextForTest()) = decompressed->size(); uint8_t dest_buf[20];
diff --git a/core/fxcodec/icc/iccmodule.cpp b/core/fxcodec/icc/iccmodule.cpp index e9a8cd6..87654c5 100644 --- a/core/fxcodec/icc/iccmodule.cpp +++ b/core/fxcodec/icc/iccmodule.cpp
@@ -10,6 +10,7 @@ #include <memory> #include <vector> +#include "core/fxcrt/fx_memory_wrappers.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" @@ -126,7 +127,8 @@ inputs[i] = pSrcValues[i]; cmsDoTransform(pTransform->transform(), inputs.data(), output, 1); } else { - std::vector<uint8_t> inputs(std::max(nSrcComponents, 16u)); + std::vector<uint8_t, FxAllocAllocator<uint8_t>> inputs( + std::max(nSrcComponents, 16u)); for (uint32_t i = 0; i < nSrcComponents; ++i) { inputs[i] = pdfium::clamp(static_cast<int>(pSrcValues[i] * 255.0f), 0, 255);
diff --git a/core/fxcodec/progressivedecoder.h b/core/fxcodec/progressivedecoder.h index 1852fe9..0247604 100644 --- a/core/fxcodec/progressivedecoder.h +++ b/core/fxcodec/progressivedecoder.h
@@ -112,7 +112,7 @@ int m_DestMin; int m_ItemSize; - std::vector<uint8_t> m_pWeightTables; + std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pWeightTables; }; class CFXCODEC_HorzTable { @@ -127,7 +127,7 @@ } int m_ItemSize; - std::vector<uint8_t> m_pWeightTables; + std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pWeightTables; }; class CFXCODEC_VertTable { @@ -141,7 +141,7 @@ pixel * m_ItemSize); } int m_ItemSize; - std::vector<uint8_t> m_pWeightTables; + std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pWeightTables; }; #ifdef PDF_ENABLE_XFA_PNG