1
0
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:
Justin Bogner 2016-11-03 18:28:04 +00:00
parent e7e3d11779
commit f1de537072
7 changed files with 16 additions and 20 deletions

View File

@ -59,8 +59,7 @@ public:
Error finalizeMsfLayout();
Expected<std::unique_ptr<DbiStream>> build(PDBFile &File,
const msf::WritableStream &Buffer);
Expected<std::unique_ptr<DbiStream>> build(PDBFile &File);
Error commit(const msf::MSFLayout &Layout,
const msf::WritableStream &Buffer);

View File

@ -43,8 +43,7 @@ public:
Error finalizeMsfLayout();
Expected<std::unique_ptr<InfoStream>>
build(PDBFile &File, const msf::WritableStream &Buffer);
Expected<std::unique_ptr<InfoStream>> build(PDBFile &File);
Error commit(const msf::MSFLayout &Layout,
const msf::WritableStream &Buffer) const;

View File

@ -56,8 +56,7 @@ public:
Error finalizeMsfLayout();
Expected<std::unique_ptr<TpiStream>> build(PDBFile &File,
const msf::WritableStream &Buffer);
Expected<std::unique_ptr<TpiStream>> build(PDBFile &File);
Error commit(const msf::MSFLayout &Layout, const msf::WritableStream &Buffer);

View File

@ -328,15 +328,15 @@ std::vector<SecMapEntry> DbiStreamBuilder::createSectionMap(
}
Expected<std::unique_ptr<DbiStream>>
DbiStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) {
DbiStreamBuilder::build(PDBFile &File) {
if (!VerHeader.hasValue())
return make_error<RawError>(raw_error_code::unspecified,
"Missing DBI Stream Version");
if (auto EC = finalize())
return std::move(EC);
auto StreamData = MappedBlockStream::createIndexedStream(File.getMsfLayout(),
Buffer, StreamDBI);
auto StreamData = MappedBlockStream::createIndexedStream(
File.getMsfLayout(), File.getMsfBuffer(), StreamDBI);
auto Dbi = llvm::make_unique<DbiStream>(File, std::move(StreamData));
Dbi->Header = Header;
Dbi->FileInfoSubstream = ReadableStreamRef(FileInfoBuffer);

View File

@ -48,9 +48,9 @@ Error InfoStreamBuilder::finalizeMsfLayout() {
}
Expected<std::unique_ptr<InfoStream>>
InfoStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) {
auto StreamData = MappedBlockStream::createIndexedStream(File.getMsfLayout(),
Buffer, StreamPDB);
InfoStreamBuilder::build(PDBFile &File) {
auto StreamData = MappedBlockStream::createIndexedStream(
File.getMsfLayout(), File.getMsfBuffer(), StreamPDB);
auto Info = llvm::make_unique<InfoStream>(std::move(StreamData));
Info->Version = Ver;
Info->Signature = Sig;

View File

@ -97,28 +97,28 @@ PDBFileBuilder::build(std::unique_ptr<msf::WritableStream> PdbFileBuffer) {
File->ContainerLayout = *ExpectedLayout;
if (Info) {
auto ExpectedInfo = Info->build(*File, *PdbFileBuffer);
auto ExpectedInfo = Info->build(*File);
if (!ExpectedInfo)
return ExpectedInfo.takeError();
File->Info = std::move(*ExpectedInfo);
}
if (Dbi) {
auto ExpectedDbi = Dbi->build(*File, *PdbFileBuffer);
auto ExpectedDbi = Dbi->build(*File);
if (!ExpectedDbi)
return ExpectedDbi.takeError();
File->Dbi = std::move(*ExpectedDbi);
}
if (Tpi) {
auto ExpectedTpi = Tpi->build(*File, *PdbFileBuffer);
auto ExpectedTpi = Tpi->build(*File);
if (!ExpectedTpi)
return ExpectedTpi.takeError();
File->Tpi = std::move(*ExpectedTpi);
}
if (Ipi) {
auto ExpectedIpi = Ipi->build(*File, *PdbFileBuffer);
auto ExpectedIpi = Ipi->build(*File);
if (!ExpectedIpi)
return ExpectedIpi.takeError();
File->Ipi = std::move(*ExpectedIpi);

View File

@ -99,16 +99,15 @@ Error TpiStreamBuilder::finalizeMsfLayout() {
return Error::success();
}
Expected<std::unique_ptr<TpiStream>>
TpiStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) {
Expected<std::unique_ptr<TpiStream>> TpiStreamBuilder::build(PDBFile &File) {
if (!VerHeader.hasValue())
return make_error<RawError>(raw_error_code::unspecified,
"Missing TPI Stream Version");
if (auto EC = finalize())
return std::move(EC);
auto StreamData =
MappedBlockStream::createIndexedStream(File.getMsfLayout(), Buffer, Idx);
auto StreamData = MappedBlockStream::createIndexedStream(
File.getMsfLayout(), File.getMsfBuffer(), Idx);
auto Tpi = llvm::make_unique<TpiStream>(File, std::move(StreamData));
Tpi->Header = Header;
Tpi->TypeRecords = VarStreamArray<codeview::CVType>(TypeRecordStream);