Remove CPDF_Stream ctor that takes a std::unique_ptr.
Switch callers to the constructor that takes a DataVector instead.
Bug: pdfium:1872
Change-Id: I228f7a33fc3b66d07e6a150690855f32eddba709
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96194
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_attachment.cpp b/fpdfsdk/fpdf_attachment.cpp
index 4a8fe27..ace3458 100644
--- a/fpdfsdk/fpdf_attachment.cpp
+++ b/fpdfsdk/fpdf_attachment.cpp
@@ -23,6 +23,7 @@
#include "core/fpdfdoc/cpdf_filespec.h"
#include "core/fpdfdoc/cpdf_nametree.h"
#include "core/fxcrt/cfx_datetime.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_memory_wrappers.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
@@ -244,10 +245,10 @@
true);
// Create the file stream and have the filespec dictionary link to it.
- std::unique_ptr<uint8_t, FxFreeDeleter> stream(FX_AllocUninit(uint8_t, len));
- memcpy(stream.get(), contents, len);
- auto pFileStream = pDoc->NewIndirect<CPDF_Stream>(std::move(stream), len,
- std::move(pFileStreamDict));
+ const uint8_t* contents_as_bytes = static_cast<const uint8_t*>(contents);
+ auto pFileStream = pDoc->NewIndirect<CPDF_Stream>(
+ DataVector<uint8_t>(contents_as_bytes, contents_as_bytes + len),
+ std::move(pFileStreamDict));
auto pEFDict = pFile->AsMutableDictionary()->SetNewFor<CPDF_Dictionary>("EF");
pEFDict->SetNewFor<CPDF_Reference>("F", pDoc, pFileStream->GetObjNum());
return true;