summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-06-22 23:36:03 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-06-22 23:36:03 +0000
commit9e0d41ab092524e8af038ee35ad66f77714667cf (patch)
tree7dadc974dabc3ba07ea44e4ab9a947dfa39e6371 /llvm/lib/MC/ELFObjectWriter.cpp
parentc05dd074e7e61b3dba8086caf36ee9151a8c0a5d (diff)
downloadbcm5719-llvm-9e0d41ab092524e8af038ee35ad66f77714667cf.tar.gz
bcm5719-llvm-9e0d41ab092524e8af038ee35ad66f77714667cf.zip
Fix PR23914.
r226830 moved the declaration of Buf to a nested scope, resulting in a dangling reference (in StringRef Name), and a use-after-free. llvm-svn: 240357
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index e7f5265384b..064e1db4783 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -842,12 +842,12 @@ void ELFObjectWriter::computeSymbolTable(
// seems that this information is not easily accessible from the
// ELFObjectWriter.
StringRef Name = Symbol.getName();
+ SmallString<32> Buf;
if (!Name.startswith("?") && !Name.startswith("@?") &&
!Name.startswith("__imp_?") && !Name.startswith("__imp_@?")) {
// This symbol isn't following the MSVC C++ name mangling convention. We
// can thus safely interpret the @@@ in symbol names as specifying symbol
// versioning.
- SmallString<32> Buf;
size_t Pos = Name.find("@@@");
if (Pos != StringRef::npos) {
Buf += Name.substr(0, Pos);
OpenPOWER on IntegriCloud