Apply UNSAFE_BUFFERS() to two-arg span ctor in testing/

Follow-on from
    https://pdfium-review.googlesource.com/c/pdfium/+/118250

-- Also include the samples/ directory, since it is related to testing
   in some sense.

Change-Id: I380f4f3b2e883002cf6a1a882d9a1f823f18caf7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118270
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/testing/fx_string_testhelpers.cpp b/testing/fx_string_testhelpers.cpp
index 798c046..363fa40 100644
--- a/testing/fx_string_testhelpers.cpp
+++ b/testing/fx_string_testhelpers.cpp
@@ -10,6 +10,7 @@
 
 #include "core/fxcrt/cfx_datetime.h"
 #include "core/fxcrt/check_op.h"
+#include "core/fxcrt/compiler_specific.h"
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/span.h"
 #include "fpdfsdk/cpdfsdk_helpers.h"
@@ -63,8 +64,11 @@
 ScopedFPDFWideString GetFPDFWideString(const std::wstring& wstr) {
   size_t length = sizeof(uint16_t) * (wstr.size() + 1);
   ScopedFPDFWideString result(static_cast<FPDF_WCHAR*>(malloc(length)));
-  pdfium::span<uint8_t> result_span(reinterpret_cast<uint8_t*>(result.get()),
-                                    length);
+
+  // SAFETY: length was argument to malloc above.
+  pdfium::span<uint8_t> result_span = UNSAFE_BUFFERS(
+      pdfium::make_span(reinterpret_cast<uint8_t*>(result.get()), length));
+
   size_t i = 0;
   for (wchar_t w : wstr) {
     result_span[i++] = w & 0xff;