Remove some more |new|s, part 11

Using vector<uint8_t> as a buffer.

Change-Id: I38a8a05e7ec1355980d17533a2c8336e733aa6f6
Reviewed-on: https://pdfium-review.googlesource.com/4791
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp
index dc99f32..16724d5 100644
--- a/fpdfsdk/fsdk_actionhandler.cpp
+++ b/fpdfsdk/fsdk_actionhandler.cpp
@@ -7,6 +7,7 @@
 #include "fpdfsdk/fsdk_actionhandler.h"
 
 #include <set>
+#include <vector>
 
 #include "core/fpdfapi/parser/cpdf_array.h"
 #include "core/fpdfdoc/cpdf_formfield.h"
@@ -420,19 +421,13 @@
   int nPageIndex = MyDest.GetPageIndex(pPDFDocument);
   int nFitType = MyDest.GetZoomMode();
   const CPDF_Array* pMyArray = ToArray(MyDest.GetObject());
-  float* pPosAry = nullptr;
-  int sizeOfAry = 0;
+  std::vector<float> posArray;
   if (pMyArray) {
-    pPosAry = new float[pMyArray->GetCount()];
-    int j = 0;
-    for (size_t i = 2; i < pMyArray->GetCount(); i++) {
-      pPosAry[j++] = pMyArray->GetFloatAt(i);
-    }
-    sizeOfAry = j;
+    for (size_t i = 2; i < pMyArray->GetCount(); i++)
+      posArray.push_back(pMyArray->GetFloatAt(i));
   }
-
-  pFormFillEnv->DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
-  delete[] pPosAry;
+  pFormFillEnv->DoGoToAction(nPageIndex, nFitType, posArray.data(),
+                             posArray.size());
 }
 
 void CPDFSDK_ActionHandler::DoAction_GoToR(
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 45c22b1..38a4c12 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -1611,24 +1611,16 @@
 
   CPDF_Dest dest(destArray);
   const CPDF_Array* arrayObject = ToArray(dest.GetObject());
-
-  std::unique_ptr<float[]> scrollPositionArray;
-  int scrollPositionArraySize = 0;
-
+  std::vector<float> scrollPositionArray;
   if (arrayObject) {
-    scrollPositionArray.reset(new float[arrayObject->GetCount()]);
-    int j = 0;
     for (size_t i = 2; i < arrayObject->GetCount(); i++)
-      scrollPositionArray[j++] = arrayObject->GetFloatAt(i);
-    scrollPositionArraySize = j;
+      scrollPositionArray.push_back(arrayObject->GetFloatAt(i));
   }
-
   pRuntime->BeginBlock();
   m_pFormFillEnv->DoGoToAction(dest.GetPageIndex(pDocument), dest.GetZoomMode(),
-                               scrollPositionArray.get(),
-                               scrollPositionArraySize);
+                               scrollPositionArray.data(),
+                               scrollPositionArray.size());
   pRuntime->EndBlock();
-
   return true;
 }
 
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 6d31d7e..c9d7c3f 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -748,12 +748,10 @@
     swLabel = newParams[4].ToCFXWideString(pRuntime);
 
   const int MAX_INPUT_BYTES = 2048;
-  std::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]);
-  memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2);
-
+  std::vector<uint8_t> pBuff(MAX_INPUT_BYTES + 2);
   int nLengthBytes = pRuntime->GetFormFillEnv()->JS_appResponse(
       swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(),
-      bPassword, pBuff.get(), MAX_INPUT_BYTES);
+      bPassword, pBuff.data(), MAX_INPUT_BYTES);
 
   if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES) {
     sError = JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG);
@@ -761,7 +759,7 @@
   }
 
   vRet = CJS_Value(pRuntime, CFX_WideString::FromUTF16LE(
-                                 reinterpret_cast<uint16_t*>(pBuff.get()),
+                                 reinterpret_cast<uint16_t*>(pBuff.data()),
                                  nLengthBytes / sizeof(uint16_t))
                                  .c_str());