diff options
| author | Yaron Keren <yaron.keren@gmail.com> | 2015-08-08 21:03:19 +0000 |
|---|---|---|
| committer | Yaron Keren <yaron.keren@gmail.com> | 2015-08-08 21:03:19 +0000 |
| commit | 3f85a22cf93bd86017b273fbddb982ed6584d84f (patch) | |
| tree | 4390a0eee43b05e99a421a42dd07fc97e3569766 /llvm/tools/dsymutil/DwarfLinker.cpp | |
| parent | fd613545cb235993108f07c8d79bd9f37ee1e80e (diff) | |
| download | bcm5719-llvm-3f85a22cf93bd86017b273fbddb982ed6584d84f.tar.gz bcm5719-llvm-3f85a22cf93bd86017b273fbddb982ed6584d84f.zip | |
Fix dangling reference in DwarfLinker.cpp. The original code
Seq.emplace_back(Seq.back());
does not work as planned, since Seq.back() may become a dangling reference
when emplace_back is called and possibly reallocates vector. To avoid this,
the vector allocation should be reserved first and only then used.
This broke test/tools/dsymutil/X86/custom-line-table.test with Visual C++ 2013.
llvm-svn: 244405
Diffstat (limited to 'llvm/tools/dsymutil/DwarfLinker.cpp')
| -rw-r--r-- | llvm/tools/dsymutil/DwarfLinker.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index 47d08504786..d839f07657b 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -2884,6 +2884,7 @@ void DwarfLinker::patchLineTableForUnit(CompileUnit &Unit, if (StopAddress != -1ULL && !Seq.empty()) { // Insert end sequence row with the computed end address, but // the same line as the previous one. + Seq.reserve(Seq.size() + 1); Seq.emplace_back(Seq.back()); Seq.back().Address = StopAddress; Seq.back().EndSequence = 1; |

