From 889a0470c20b0d3a1d534efaf94d5b98a1d45fc1 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 2 Jul 2018 23:21:23 +0000 Subject: Kill a malloc/memcpy in cjs_document.cpp Change-Id: Icdbdd1c0e5052490c251009b5b2b31b2c46fb580 Reviewed-on: https://pdfium-review.googlesource.com/36833 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- fxjs/cjs_document.cpp | 9 +++------ 1 file 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 pMutableBuf(FX_Alloc(char, nBufSize)); - memcpy(pMutableBuf.get(), sTextBuf.c_str(), nBufSize); + std::vector 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(); } -- cgit v1.2.3