diff --git a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp --- a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp +++ b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp @@ -126,9 +126,11 @@ Sec.SectionType = llvm::wasm::WASM_SEC_CUSTOM; Sec.Name = NewSection.SectionName; + llvm::StringRef InputData = + llvm::StringRef(NewSection.SectionData->getBufferStart(), + NewSection.SectionData->getBufferSize()); std::unique_ptr BufferCopy = MemoryBuffer::getMemBufferCopy( - NewSection.SectionData->getBufferStart(), - NewSection.SectionData->getBufferIdentifier()); + InputData, NewSection.SectionData->getBufferIdentifier()); Sec.Contents = makeArrayRef( reinterpret_cast(BufferCopy->getBufferStart()), BufferCopy->getBufferSize());