Fix uninitialized read.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304846 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner 2017-06-06 23:54:23 +00:00
parent 3dfb196736
commit 2f4ae78089
3 changed files with 14 additions and 9 deletions

View File

@ -96,7 +96,8 @@ private:
FixedStreamArray<support::ulittle16_t> DbgStreams;
PdbRaw_DbiSecContribVer SectionContribVersion;
PdbRaw_DbiSecContribVer SectionContribVersion =
PdbRaw_DbiSecContribVer::DbiSecContribVer60;
FixedStreamArray<SectionContrib> SectionContribs;
FixedStreamArray<SectionContrib2> SectionContribs2;
FixedStreamArray<SecMapEntry> SectionMap;

View File

@ -38,12 +38,12 @@ template <> struct BinaryItemTraits<CVSymbol> {
static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize,
uint32_t C13Size) {
uint32_t Size = sizeof(uint32_t); // Signature
Size += SymbolByteSize; // Symbol Data
Size += 0; // TODO: Layout.C11Bytes
Size += C13Size; // C13 Debug Info Size
Size += sizeof(uint32_t); // GlobalRefs substream size (always 0)
Size += 0; // GlobalRefs substream bytes
uint32_t Size = sizeof(uint32_t); // Signature
Size += alignTo(SymbolByteSize, 4); // Symbol Data
Size += 0; // TODO: Layout.C11Bytes
Size += C13Size; // C13 Debug Info Size
Size += sizeof(uint32_t); // GlobalRefs substream size (always 0)
Size += 0; // GlobalRefs substream bytes
return Size;
}
@ -156,6 +156,8 @@ Error DbiModuleDescriptorBuilder::commit(BinaryStreamWriter &ModiWriter,
BinaryStreamRef RecordsRef(Records);
if (auto EC = SymbolWriter.writeStreamRef(RecordsRef))
return EC;
if (auto EC = SymbolWriter.padToAlignment(4))
return EC;
// TODO: Write C11 Line data
assert(SymbolWriter.getOffset() % alignOf(CodeViewContainer::Pdb) == 0 &&
"Invalid debug section alignment!");

View File

@ -216,10 +216,12 @@ FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const {
void DbiStream::visitSectionContributions(
ISectionContribVisitor &Visitor) const {
if (SectionContribVersion == DbiSecContribVer60) {
if (!SectionContribs.empty()) {
assert(SectionContribVersion == DbiSecContribVer60);
for (auto &SC : SectionContribs)
Visitor.visit(SC);
} else if (SectionContribVersion == DbiSecContribV2) {
} else if (!SectionContribs2.empty()) {
assert(SectionContribVersion == DbiSecContribV2);
for (auto &SC : SectionContribs2)
Visitor.visit(SC);
}