[llvm] r312590 - Fix a use after free.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 16:00:51 PDT 2017
Author: rafael
Date: Tue Sep 5 16:00:51 2017
New Revision: 312590
URL: http://llvm.org/viewvc/llvm-project?rev=312590&view=rev
Log:
Fix a use after free.
Modified:
llvm/trunk/tools/obj2yaml/elf2yaml.cpp
Modified: llvm/trunk/tools/obj2yaml/elf2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/elf2yaml.cpp?rev=312590&r1=312589&r2=312590&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/elf2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/elf2yaml.cpp Tue Sep 5 16:00:51 2017
@@ -80,11 +80,11 @@ ELFDumper<ELFT>::getUniquedSectionName(c
if (!NameOrErr)
return NameOrErr;
StringRef Name = *NameOrErr;
- std::string Ret = Name;
+ std::string &Ret = SectionNames[SecIndex];
+ Ret = Name;
while (!UsedSectionNames.insert(Ret).second)
Ret = (Name + to_string(++Suffix)).str();
- SectionNames[SecIndex] = Ret;
- return SectionNames[SecIndex];
+ return Ret;
}
template <class ELFT> ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
More information about the llvm-commits
mailing list