mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
PDB: Fix some APIs to avoid use-after-frees
The buffer is already owned by the PDBFile for all of these APIs, so don't pass it in separately. llvm-svn: 285953
This commit is contained in:
parent
e7e3d11779
commit
f1de537072
@ -59,8 +59,7 @@ public:
|
|||||||
|
|
||||||
Error finalizeMsfLayout();
|
Error finalizeMsfLayout();
|
||||||
|
|
||||||
Expected<std::unique_ptr<DbiStream>> build(PDBFile &File,
|
Expected<std::unique_ptr<DbiStream>> build(PDBFile &File);
|
||||||
const msf::WritableStream &Buffer);
|
|
||||||
Error commit(const msf::MSFLayout &Layout,
|
Error commit(const msf::MSFLayout &Layout,
|
||||||
const msf::WritableStream &Buffer);
|
const msf::WritableStream &Buffer);
|
||||||
|
|
||||||
|
@ -43,8 +43,7 @@ public:
|
|||||||
|
|
||||||
Error finalizeMsfLayout();
|
Error finalizeMsfLayout();
|
||||||
|
|
||||||
Expected<std::unique_ptr<InfoStream>>
|
Expected<std::unique_ptr<InfoStream>> build(PDBFile &File);
|
||||||
build(PDBFile &File, const msf::WritableStream &Buffer);
|
|
||||||
|
|
||||||
Error commit(const msf::MSFLayout &Layout,
|
Error commit(const msf::MSFLayout &Layout,
|
||||||
const msf::WritableStream &Buffer) const;
|
const msf::WritableStream &Buffer) const;
|
||||||
|
@ -56,8 +56,7 @@ public:
|
|||||||
|
|
||||||
Error finalizeMsfLayout();
|
Error finalizeMsfLayout();
|
||||||
|
|
||||||
Expected<std::unique_ptr<TpiStream>> build(PDBFile &File,
|
Expected<std::unique_ptr<TpiStream>> build(PDBFile &File);
|
||||||
const msf::WritableStream &Buffer);
|
|
||||||
|
|
||||||
Error commit(const msf::MSFLayout &Layout, const msf::WritableStream &Buffer);
|
Error commit(const msf::MSFLayout &Layout, const msf::WritableStream &Buffer);
|
||||||
|
|
||||||
|
@ -328,15 +328,15 @@ std::vector<SecMapEntry> DbiStreamBuilder::createSectionMap(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Expected<std::unique_ptr<DbiStream>>
|
Expected<std::unique_ptr<DbiStream>>
|
||||||
DbiStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) {
|
DbiStreamBuilder::build(PDBFile &File) {
|
||||||
if (!VerHeader.hasValue())
|
if (!VerHeader.hasValue())
|
||||||
return make_error<RawError>(raw_error_code::unspecified,
|
return make_error<RawError>(raw_error_code::unspecified,
|
||||||
"Missing DBI Stream Version");
|
"Missing DBI Stream Version");
|
||||||
if (auto EC = finalize())
|
if (auto EC = finalize())
|
||||||
return std::move(EC);
|
return std::move(EC);
|
||||||
|
|
||||||
auto StreamData = MappedBlockStream::createIndexedStream(File.getMsfLayout(),
|
auto StreamData = MappedBlockStream::createIndexedStream(
|
||||||
Buffer, StreamDBI);
|
File.getMsfLayout(), File.getMsfBuffer(), StreamDBI);
|
||||||
auto Dbi = llvm::make_unique<DbiStream>(File, std::move(StreamData));
|
auto Dbi = llvm::make_unique<DbiStream>(File, std::move(StreamData));
|
||||||
Dbi->Header = Header;
|
Dbi->Header = Header;
|
||||||
Dbi->FileInfoSubstream = ReadableStreamRef(FileInfoBuffer);
|
Dbi->FileInfoSubstream = ReadableStreamRef(FileInfoBuffer);
|
||||||
|
@ -48,9 +48,9 @@ Error InfoStreamBuilder::finalizeMsfLayout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Expected<std::unique_ptr<InfoStream>>
|
Expected<std::unique_ptr<InfoStream>>
|
||||||
InfoStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) {
|
InfoStreamBuilder::build(PDBFile &File) {
|
||||||
auto StreamData = MappedBlockStream::createIndexedStream(File.getMsfLayout(),
|
auto StreamData = MappedBlockStream::createIndexedStream(
|
||||||
Buffer, StreamPDB);
|
File.getMsfLayout(), File.getMsfBuffer(), StreamPDB);
|
||||||
auto Info = llvm::make_unique<InfoStream>(std::move(StreamData));
|
auto Info = llvm::make_unique<InfoStream>(std::move(StreamData));
|
||||||
Info->Version = Ver;
|
Info->Version = Ver;
|
||||||
Info->Signature = Sig;
|
Info->Signature = Sig;
|
||||||
|
@ -97,28 +97,28 @@ PDBFileBuilder::build(std::unique_ptr<msf::WritableStream> PdbFileBuffer) {
|
|||||||
File->ContainerLayout = *ExpectedLayout;
|
File->ContainerLayout = *ExpectedLayout;
|
||||||
|
|
||||||
if (Info) {
|
if (Info) {
|
||||||
auto ExpectedInfo = Info->build(*File, *PdbFileBuffer);
|
auto ExpectedInfo = Info->build(*File);
|
||||||
if (!ExpectedInfo)
|
if (!ExpectedInfo)
|
||||||
return ExpectedInfo.takeError();
|
return ExpectedInfo.takeError();
|
||||||
File->Info = std::move(*ExpectedInfo);
|
File->Info = std::move(*ExpectedInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Dbi) {
|
if (Dbi) {
|
||||||
auto ExpectedDbi = Dbi->build(*File, *PdbFileBuffer);
|
auto ExpectedDbi = Dbi->build(*File);
|
||||||
if (!ExpectedDbi)
|
if (!ExpectedDbi)
|
||||||
return ExpectedDbi.takeError();
|
return ExpectedDbi.takeError();
|
||||||
File->Dbi = std::move(*ExpectedDbi);
|
File->Dbi = std::move(*ExpectedDbi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tpi) {
|
if (Tpi) {
|
||||||
auto ExpectedTpi = Tpi->build(*File, *PdbFileBuffer);
|
auto ExpectedTpi = Tpi->build(*File);
|
||||||
if (!ExpectedTpi)
|
if (!ExpectedTpi)
|
||||||
return ExpectedTpi.takeError();
|
return ExpectedTpi.takeError();
|
||||||
File->Tpi = std::move(*ExpectedTpi);
|
File->Tpi = std::move(*ExpectedTpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ipi) {
|
if (Ipi) {
|
||||||
auto ExpectedIpi = Ipi->build(*File, *PdbFileBuffer);
|
auto ExpectedIpi = Ipi->build(*File);
|
||||||
if (!ExpectedIpi)
|
if (!ExpectedIpi)
|
||||||
return ExpectedIpi.takeError();
|
return ExpectedIpi.takeError();
|
||||||
File->Ipi = std::move(*ExpectedIpi);
|
File->Ipi = std::move(*ExpectedIpi);
|
||||||
|
@ -99,16 +99,15 @@ Error TpiStreamBuilder::finalizeMsfLayout() {
|
|||||||
return Error::success();
|
return Error::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
Expected<std::unique_ptr<TpiStream>>
|
Expected<std::unique_ptr<TpiStream>> TpiStreamBuilder::build(PDBFile &File) {
|
||||||
TpiStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) {
|
|
||||||
if (!VerHeader.hasValue())
|
if (!VerHeader.hasValue())
|
||||||
return make_error<RawError>(raw_error_code::unspecified,
|
return make_error<RawError>(raw_error_code::unspecified,
|
||||||
"Missing TPI Stream Version");
|
"Missing TPI Stream Version");
|
||||||
if (auto EC = finalize())
|
if (auto EC = finalize())
|
||||||
return std::move(EC);
|
return std::move(EC);
|
||||||
|
|
||||||
auto StreamData =
|
auto StreamData = MappedBlockStream::createIndexedStream(
|
||||||
MappedBlockStream::createIndexedStream(File.getMsfLayout(), Buffer, Idx);
|
File.getMsfLayout(), File.getMsfBuffer(), Idx);
|
||||||
auto Tpi = llvm::make_unique<TpiStream>(File, std::move(StreamData));
|
auto Tpi = llvm::make_unique<TpiStream>(File, std::move(StreamData));
|
||||||
Tpi->Header = Header;
|
Tpi->Header = Header;
|
||||||
Tpi->TypeRecords = VarStreamArray<codeview::CVType>(TypeRecordStream);
|
Tpi->TypeRecords = VarStreamArray<codeview::CVType>(TypeRecordStream);
|
||||||
|
Loading…
Reference in New Issue
Block a user