summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-02 23:21:23 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-02 23:21:23 +0000
commit889a0470c20b0d3a1d534efaf94d5b98a1d45fc1 (patch)
tree8f2edfa3924a4e2ac7e2d98b8c4d0a62f036310a
parentc9aa2f8bfdf74ffae633c7bb1a4d908dda9caed5 (diff)
downloadpdfium-889a0470c20b0d3a1d534efaf94d5b98a1d45fc1.tar.xz
Kill a malloc/memcpy in cjs_document.cpp
Change-Id: Icdbdd1c0e5052490c251009b5b2b31b2c46fb580 Reviewed-on: https://pdfium-review.googlesource.com/36833 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--fxjs/cjs_document.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index b22d31b0b4..35e3e53437 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -326,15 +326,12 @@ CJS_Return CJS_Document::mailForm(
WideString cBcc = nLength > 3 ? pRuntime->ToWideString(params[3]) : L"";
WideString cSubject = nLength > 4 ? pRuntime->ToWideString(params[4]) : L"";
WideString cMsg = nLength > 5 ? pRuntime->ToWideString(params[5]) : L"";
-
- size_t nBufSize = sTextBuf.GetLength();
- std::unique_ptr<char, FxFreeDeleter> pMutableBuf(FX_Alloc(char, nBufSize));
- memcpy(pMutableBuf.get(), sTextBuf.c_str(), nBufSize);
+ std::vector<char> mutable_buf(sTextBuf.begin(), sTextBuf.end());
pRuntime->BeginBlock();
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
- pFormFillEnv->JS_docmailForm(pMutableBuf.get(), nBufSize, bUI, cTo, cSubject,
- cCc, cBcc, cMsg);
+ pFormFillEnv->JS_docmailForm(mutable_buf.data(), mutable_buf.size(), bUI, cTo,
+ cSubject, cCc, cBcc, cMsg);
pRuntime->EndBlock();
return CJS_Return();
}