summaryrefslogtreecommitdiff
path: root/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
commit1ccd91a5b156ff8b415806b0d60fd7c302d62693 (patch)
treeb0850a0d4176e01e042e509dcebb62e68160e3b4 /lib/MC/MCSection.cpp
parent3f4dcd92daef80f87919507b6baf2a97d4bfaa2e (diff)
Put MCSectionCOFF::Name into the MCContext instead of leaking it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCSection.cpp')
-rw-r--r--lib/MC/MCSection.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/MC/MCSection.cpp b/lib/MC/MCSection.cpp
index 24c89efefc6..f6e96368eb2 100644
--- a/lib/MC/MCSection.cpp
+++ b/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,