aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCSection.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2010-03-22 23:26:12 +0000
committerJeffrey Yasskin <jyasskin@google.com>2010-03-22 23:26:12 +0000
commita99d2328035505e364400860fa8114e4666689ed (patch)
tree3deceb838055c1f8127a13ebd14710b82a6c506d /llvm/lib/MC/MCSection.cpp
parent00c291b01299b42692c3fccffd630515809decc1 (diff)
downloadllvm-a99d2328035505e364400860fa8114e4666689ed.zip
llvm-a99d2328035505e364400860fa8114e4666689ed.tar.gz
llvm-a99d2328035505e364400860fa8114e4666689ed.tar.bz2
Put MCSectionCOFF::Name into the MCContext instead of leaking it.
llvm-svn: 99231
Diffstat (limited to 'llvm/lib/MC/MCSection.cpp')
-rw-r--r--llvm/lib/MC/MCSection.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp
index 24c89ef..f6e9636 100644
--- a/llvm/lib/MC/MCSection.cpp
+++ b/llvm/lib/MC/MCSection.cpp
@@ -26,7 +26,11 @@ MCSection::~MCSection() {
MCSectionCOFF *MCSectionCOFF::
Create(StringRef Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
- return new (Ctx) MCSectionCOFF(Name, IsDirective, K);
+ char *NameCopy = static_cast<char*>(
+ Ctx.Allocate(Name.size(), /*Alignment=*/1));
+ memcpy(NameCopy, Name.data(), Name.size());
+ return new (Ctx) MCSectionCOFF(StringRef(NameCopy, Name.size()),
+ IsDirective, K);
}
void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,