Fix use after free in BinaryStream library.
This was reported by the ASAN bot, and it turned out to be a fairly fundamental problem with the design of VarStreamArray and the way it passes context information to the extractor. The fix was cumbersome, and I'm not entirely pleased with it, so I plan to revisit this design in the future when I'm not pressed to get the bots green again. For now, this fixes the issue by storing the context information by value instead of by reference, and introduces some impossibly-confusing template magic to make things "work". llvm-svn: 301999
This commit is contained in:
@@ -17,13 +17,13 @@ using namespace llvm::codeview;
|
||||
|
||||
Error VarStreamArrayExtractor<InlineeSourceLine>::extract(
|
||||
BinaryStreamRef Stream, uint32_t &Len, InlineeSourceLine &Item,
|
||||
ContextType *Fragment) {
|
||||
bool HasExtraFiles) {
|
||||
BinaryStreamReader Reader(Stream);
|
||||
|
||||
if (auto EC = Reader.readObject(Item.Header))
|
||||
return EC;
|
||||
|
||||
if (Fragment->hasExtraFiles()) {
|
||||
if (HasExtraFiles) {
|
||||
uint32_t ExtraFileCount;
|
||||
if (auto EC = Reader.readInteger(ExtraFileCount))
|
||||
return EC;
|
||||
@@ -42,7 +42,8 @@ Error ModuleDebugInlineeLineFragmentRef::initialize(BinaryStreamReader Reader) {
|
||||
if (auto EC = Reader.readEnum(Signature))
|
||||
return EC;
|
||||
|
||||
if (auto EC = Reader.readArray(Lines, Reader.bytesRemaining(), this))
|
||||
if (auto EC =
|
||||
Reader.readArray(Lines, Reader.bytesRemaining(), hasExtraFiles()))
|
||||
return EC;
|
||||
|
||||
assert(Reader.bytesRemaining() == 0);
|
||||
|
||||
Reference in New Issue
Block a user