Use StringRef::substr instead of std::string::substr to avoid using a free'd
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 12 Mar 2010 13:54:59 +0000 (13:54 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 12 Mar 2010 13:54:59 +0000 (13:54 +0000)
string temporary. This should fix PR6590.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98349 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp

index fc30b134e015fe5669ff3b4448a2b351389b99e3..8c09eecd4f6c98e18c087b8832bc3f19c880815c 100644 (file)
@@ -9837,7 +9837,8 @@ bool X86TargetLowering::ExpandInlineAsm(CallInst *CI) const {
         AsmPieces[2] == "${0:w}" &&
         IA->getConstraintString().compare(0, 5, "=r,0,") == 0) {
       AsmPieces.clear();
-      SplitString(IA->getConstraintString().substr(5), AsmPieces, ",");
+      const std::string &Constraints = IA->getConstraintString();
+      SplitString(StringRef(Constraints).substr(5), AsmPieces, ",");
       std::sort(AsmPieces.begin(), AsmPieces.end());
       if (AsmPieces.size() == 4 &&
           AsmPieces[0] == "~{cc}" &&