[llvm] r304846 - Fix uninitialized read.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 16:54:24 PDT 2017
Author: zturner
Date: Tue Jun 6 18:54:23 2017
New Revision: 304846
URL: http://llvm.org/viewvc/llvm-project?rev=304846&view=rev
Log:
Fix uninitialized read.
Modified:
llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
llvm/trunk/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h?rev=304846&r1=304845&r2=304846&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h Tue Jun 6 18:54:23 2017
@@ -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;
Modified: llvm/trunk/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp?rev=304846&r1=304845&r2=304846&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp Tue Jun 6 18:54:23 2017
@@ -38,12 +38,12 @@ template <> struct BinaryItemTraits<CVSy
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
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!");
Modified: llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp?rev=304846&r1=304845&r2=304846&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp Tue Jun 6 18:54:23 2017
@@ -216,10 +216,12 @@ FixedStreamArray<SecMapEntry> DbiStream:
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);
}
More information about the llvm-commits
mailing list