Rework strange code in GetPlatformWString().

It happens to work since post-C++11 assigning to the null terminator
is allowed so long as the value being assigned is also null, but it
looks like a bounds error to the casual reader.

Change-Id: I5d36bea264dc94ae6146d0742e819cc4fff2e183
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93770
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/testing/fx_string_testhelpers.cpp b/testing/fx_string_testhelpers.cpp
index 7949b7a..228f7d4 100644
--- a/testing/fx_string_testhelpers.cpp
+++ b/testing/fx_string_testhelpers.cpp
@@ -51,10 +51,11 @@
   while (wstr[characters])
     ++characters;
 
-  std::wstring platform_string(characters, L'\0');
-  for (size_t i = 0; i < characters + 1; ++i) {
+  std::wstring platform_string;
+  platform_string.reserve(characters);
+  for (size_t i = 0; i < characters; ++i) {
     const unsigned char* ptr = reinterpret_cast<const unsigned char*>(&wstr[i]);
-    platform_string[i] = ptr[0] + 256 * ptr[1];
+    platform_string.push_back(ptr[0] + 256 * ptr[1]);
   }
   return platform_string;
 }