[llvm] r232335 - [dsymutil] Add missing raw_svector_stream::resync() calls.
Frederic Riss
friss at apple.com
Sun Mar 15 15:20:28 PDT 2015
Author: friss
Date: Sun Mar 15 17:20:28 2015
New Revision: 232335
URL: http://llvm.org/viewvc/llvm-project?rev=232335&view=rev
Log:
[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.
Modified:
llvm/trunk/tools/dsymutil/DwarfLinker.cpp
Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=232335&r1=232334&r2=232335&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Sun Mar 15 17:20:28 2015
@@ -722,7 +722,7 @@ void DwarfStreamer::emitLineTableForUnit
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
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
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
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
MS->EmitBytes(EncodingOS.str());
LineSectionSize += EncodingBuffer.size();
EncodingBuffer.resize(0);
+ EncodingOS.resync();
}
MS->EmitLabel(LineEndSym);
More information about the llvm-commits
mailing list