diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-05-02 13:19:56 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-02 21:11:41 +0000 |
commit | 4ad46903002d9dff92b3f05d34a7ff73d74ee2c1 (patch) | |
tree | d1f196c34e44538b8c088551f63dbed0b640c7f6 /fpdfsdk/fpdfxfa | |
parent | b8e89e3182109ff3d93ee5f2ff9b5314af95d548 (diff) | |
download | pdfium-4ad46903002d9dff92b3f05d34a7ff73d74ee2c1.tar.xz |
Remove some |new|s in cpdfsdk_formfillenvironment.cpp and cpdfxfa_context.cpp
Use std::vector<uint8_t> as buffer instead.
Change-Id: I710fe87f292b2c0f838410e9c7ff615c27c589a6
Reviewed-on: https://pdfium-review.googlesource.com/4790
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index 57735426e7..bda0128f18 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -6,6 +6,7 @@ #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" +#include <algorithm> #include <utility> #include "core/fpdfapi/parser/cpdf_document.h" @@ -307,25 +308,22 @@ CFX_WideString CPDFXFA_Context::Response(const CFX_WideString& wsQuestion, const CFX_WideString& wsTitle, const CFX_WideString& wsDefaultAnswer, bool bMark) { - CFX_WideString wsAnswer; if (!m_pFormFillEnv) - return wsAnswer; + return CFX_WideString(); int nLength = 2048; - char* pBuff = new char[nLength]; + std::vector<uint8_t> pBuff(nLength); nLength = m_pFormFillEnv->JS_appResponse(wsQuestion.c_str(), wsTitle.c_str(), wsDefaultAnswer.c_str(), nullptr, - bMark, pBuff, nLength); - if (nLength > 0) { - nLength = nLength > 2046 ? 2046 : nLength; - pBuff[nLength] = 0; - pBuff[nLength + 1] = 0; - wsAnswer = CFX_WideString::FromUTF16LE( - reinterpret_cast<const unsigned short*>(pBuff), - nLength / sizeof(unsigned short)); - } - delete[] pBuff; - return wsAnswer; + bMark, pBuff.data(), nLength); + if (nLength <= 0) + return CFX_WideString(); + + nLength = std::min(2046, nLength); + pBuff[nLength] = 0; + pBuff[nLength + 1] = 0; + return CFX_WideString::FromUTF16LE(reinterpret_cast<uint16_t*>(pBuff.data()), + nLength / sizeof(uint16_t)); } CFX_RetainPtr<IFX_SeekableReadStream> CPDFXFA_Context::DownloadURL( |