diff options
author | Che-Liang Chiou <clchiou@gmail.com> | 2010-12-01 11:45:53 +0000 |
---|---|---|
committer | Che-Liang Chiou <clchiou@gmail.com> | 2010-12-01 11:45:53 +0000 |
commit | 3608d2ac67f22485f8cb23420b98392ae7685d6d (patch) | |
tree | 7c2493839fa91df11f3c5158914df174db42cb93 /lib/Target/PTX | |
parent | 7a874ddda037349184fbeb22838cc11a1a9bb78f (diff) | |
download | external_llvm-3608d2ac67f22485f8cb23420b98392ae7685d6d.zip external_llvm-3608d2ac67f22485f8cb23420b98392ae7685d6d.tar.gz external_llvm-3608d2ac67f22485f8cb23420b98392ae7685d6d.tar.bz2 |
ptx: bug fix: use after free
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PTX')
-rw-r--r-- | lib/Target/PTX/PTXAsmPrinter.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Target/PTX/PTXAsmPrinter.cpp b/lib/Target/PTX/PTXAsmPrinter.cpp index 8fb1f53..f452552 100644 --- a/lib/Target/PTX/PTXAsmPrinter.cpp +++ b/lib/Target/PTX/PTXAsmPrinter.cpp @@ -130,20 +130,21 @@ void PTXAsmPrinter::EmitFunctionBodyStart() { } void PTXAsmPrinter::EmitInstruction(const MachineInstr *MI) { - SmallString<128> sstr; - raw_svector_ostream OS(sstr); + std::string str; + str.reserve(64); + + // Write instruction to str + raw_string_ostream OS(str); printInstruction(MI, OS); OS << ';'; + OS.flush(); // Replace "%type" if found - StringRef strref = OS.str(); size_t pos; - if ((pos = strref.find("%type")) != StringRef::npos) { - std::string str = strref; + if ((pos = str.find("%type")) != std::string::npos) str.replace(pos, /*strlen("%type")==*/5, getInstructionTypeName(MI)); - strref = StringRef(str); - } + StringRef strref = StringRef(str); OutStreamer.EmitRawText(strref); } |