Use buffers from the partition in CPDFSDK_FormFillEnvironment
- fix string_view_template.h to take an Allocator Type argument.
Change-Id: Ia67bebc8ad0d1145d7fd09e81a9c0e49e17798fd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/62752
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index 32f25cc..4a7c4a6 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -73,7 +73,9 @@
: m_Span(reinterpret_cast<const UnsignedType*>(&ch), 1) {}
// Any changes to |vec| invalidate the string.
- explicit StringViewTemplate(const std::vector<UnsignedType>& vec) noexcept
+ template <typename AllocType>
+ explicit StringViewTemplate(
+ const std::vector<UnsignedType, AllocType>& vec) noexcept
: m_Span(!vec.empty() ? vec.data() : nullptr, vec.size()) {}
StringViewTemplate& operator=(const CharType* src) {
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index 3c1dae5..8f9bdd1 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -8,10 +8,12 @@
#include <memory>
#include <utility>
+#include <vector>
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfdoc/cpdf_docjsactions.h"
+#include "core/fxcrt/fx_memory_wrappers.h"
#include "fpdfsdk/cpdfsdk_actionhandler.h"
#include "fpdfsdk/cpdfsdk_annothandlermgr.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
@@ -128,7 +130,7 @@
if (nRequiredLen <= 0)
return WideString();
- std::vector<uint8_t> pBuff(nRequiredLen);
+ std::vector<uint8_t, FxAllocAllocator<uint8_t>> pBuff(nRequiredLen);
int nActualLen =
m_pInfo->FFI_GetLanguage(m_pInfo, pBuff.data(), nRequiredLen);
if (nActualLen <= 0 || nActualLen > nRequiredLen)
@@ -150,7 +152,7 @@
if (nRequiredLen <= 0)
return WideString();
- std::vector<uint8_t> pBuff(nRequiredLen);
+ std::vector<uint8_t, FxAllocAllocator<uint8_t>> pBuff(nRequiredLen);
int nActualLen =
m_pInfo->FFI_GetPlatform(m_pInfo, pBuff.data(), nRequiredLen);
if (nActualLen <= 0 || nActualLen > nRequiredLen)
@@ -218,7 +220,7 @@
if (nRequiredLen <= 0)
return WideString();
- std::vector<uint8_t> pBuff(nRequiredLen);
+ std::vector<uint8_t, FxAllocAllocator<uint8_t>> pBuff(nRequiredLen);
const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse(
m_pInfo->m_pJsPlatform, pBuff.data(), nRequiredLen);
if (nActualLen <= 0 || nActualLen > nRequiredLen)
@@ -291,7 +293,7 @@
if (nRequiredLen <= 0)
return WideString();
- std::vector<uint8_t> pBuff(nRequiredLen);
+ std::vector<uint8_t, FxAllocAllocator<uint8_t>> pBuff(nRequiredLen);
const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(
m_pInfo->m_pJsPlatform, pBuff.data(), nRequiredLen);
if (nActualLen <= 0 || nActualLen > nRequiredLen)