From: Frederic Riss Date: Sun, 15 Mar 2015 22:20:28 +0000 (+0000) Subject: [dsymutil] Add missing raw_svector_stream::resync() calls. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e21a4196a1473520eeaafe791b53622f1f821175;p=oota-llvm.git [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 --- diff --git a/tools/dsymutil/DwarfLinker.cpp b/tools/dsymutil/DwarfLinker.cpp index 6e61afd7053..5c26f91079e 100644 --- a/tools/dsymutil/DwarfLinker.cpp +++ b/tools/dsymutil/DwarfLinker.cpp @@ -722,7 +722,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes, MS->EmitBytes(PrologueBytes); LineSectionSize += PrologueBytes.size() + 4; - SmallString<16> EncodingBuffer; + SmallString<128> EncodingBuffer; raw_svector_ostream EncodingOS(EncodingBuffer); if (Rows.empty()) { @@ -731,7 +731,6 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes, MCDwarfLineAddr::Encode(*MC, INT64_MAX, 0, EncodingOS); MS->EmitBytes(EncodingOS.str()); LineSectionSize += EncodingBuffer.size(); - EncodingBuffer.resize(0); MS->EmitLabel(LineEndSym); return; } @@ -815,6 +814,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes, MS->EmitBytes(EncodingOS.str()); LineSectionSize += EncodingBuffer.size(); EncodingBuffer.resize(0); + EncodingOS.resync(); Address = Row.Address; LastLine = Row.Line; RowsSinceLastSequence++; @@ -833,7 +833,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes, MS->EmitBytes(EncodingOS.str()); LineSectionSize += EncodingBuffer.size(); EncodingBuffer.resize(0); - + EncodingOS.resync(); Address = -1ULL; LastLine = FileNum = IsStatement = 1; RowsSinceLastSequence = Column = Isa = 0; @@ -845,6 +845,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes, MS->EmitBytes(EncodingOS.str()); LineSectionSize += EncodingBuffer.size(); EncodingBuffer.resize(0); + EncodingOS.resync(); } MS->EmitLabel(LineEndSym);