From: Frederic Riss Date: Sun, 15 Mar 2015 22:20:28 +0000 (+0000) Subject: [dsymutil] Add missing raw_svector_stream::resync() calls. X-Git-Tag: llvmorg-3.7.0-rc1~9165 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3820d09c783d141bb6a5b8f180e0e3870c429dc;p=platform%2Fupstream%2Fllvm.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. llvm-svn: 232335 --- diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index 6e61afd..5c26f91 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/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);