[dsymutil] Add missing raw_svector_stream::resync() calls.

Also, after looking at the raw_svector_stream internals, increase the
size of the SmallString used with it to prevent heap allocation.

Issue found by the Asan bot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232335 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frederic Riss 2015-03-15 22:20:28 +00:00
parent dca78825b7
commit e21a4196a1

View File

@ -722,7 +722,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes,
MS->EmitBytes(PrologueBytes); MS->EmitBytes(PrologueBytes);
LineSectionSize += PrologueBytes.size() + 4; LineSectionSize += PrologueBytes.size() + 4;
SmallString<16> EncodingBuffer; SmallString<128> EncodingBuffer;
raw_svector_ostream EncodingOS(EncodingBuffer); raw_svector_ostream EncodingOS(EncodingBuffer);
if (Rows.empty()) { if (Rows.empty()) {
@ -731,7 +731,6 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes,
MCDwarfLineAddr::Encode(*MC, INT64_MAX, 0, EncodingOS); MCDwarfLineAddr::Encode(*MC, INT64_MAX, 0, EncodingOS);
MS->EmitBytes(EncodingOS.str()); MS->EmitBytes(EncodingOS.str());
LineSectionSize += EncodingBuffer.size(); LineSectionSize += EncodingBuffer.size();
EncodingBuffer.resize(0);
MS->EmitLabel(LineEndSym); MS->EmitLabel(LineEndSym);
return; return;
} }
@ -815,6 +814,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes,
MS->EmitBytes(EncodingOS.str()); MS->EmitBytes(EncodingOS.str());
LineSectionSize += EncodingBuffer.size(); LineSectionSize += EncodingBuffer.size();
EncodingBuffer.resize(0); EncodingBuffer.resize(0);
EncodingOS.resync();
Address = Row.Address; Address = Row.Address;
LastLine = Row.Line; LastLine = Row.Line;
RowsSinceLastSequence++; RowsSinceLastSequence++;
@ -833,7 +833,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes,
MS->EmitBytes(EncodingOS.str()); MS->EmitBytes(EncodingOS.str());
LineSectionSize += EncodingBuffer.size(); LineSectionSize += EncodingBuffer.size();
EncodingBuffer.resize(0); EncodingBuffer.resize(0);
EncodingOS.resync();
Address = -1ULL; Address = -1ULL;
LastLine = FileNum = IsStatement = 1; LastLine = FileNum = IsStatement = 1;
RowsSinceLastSequence = Column = Isa = 0; RowsSinceLastSequence = Column = Isa = 0;
@ -845,6 +845,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes,
MS->EmitBytes(EncodingOS.str()); MS->EmitBytes(EncodingOS.str());
LineSectionSize += EncodingBuffer.size(); LineSectionSize += EncodingBuffer.size();
EncodingBuffer.resize(0); EncodingBuffer.resize(0);
EncodingOS.resync();
} }
MS->EmitLabel(LineEndSym); MS->EmitLabel(LineEndSym);