[llvm-commits] [dragonegg] r159205 - /dragonegg/trunk/src/Backend.cpp

Duncan Sands baldrick at free.fr
Tue Jun 26 07:47:44 PDT 2012


Author: baldrick
Date: Tue Jun 26 09:47:43 2012
New Revision: 159205

URL: http://llvm.org/viewvc/llvm-project?rev=159205&view=rev
Log:
Fix possible memory corruption introduced in commit 159022 ("Make it possible to
easily override any part of the target triple...").  The Parts array is indexing
into the TargetTriple std::string, so writing to TargetTriple can invalidate it.

Modified:
    dragonegg/trunk/src/Backend.cpp

Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=159205&r1=159204&r2=159205&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Tue Jun 26 09:47:43 2012
@@ -413,10 +413,10 @@
 
   if (Parts.size() == 0)
     return "";
-  TargetTriple = Parts[0];
+  std::string NewTriple = Parts[0];
   for (unsigned i = 1; i != Parts.size(); ++i)
-    TargetTriple += (Twine("-") + Parts[i]).str();
-  return TargetTriple;
+    NewTriple += (Twine("-") + Parts[i]).str();
+  return NewTriple;
 }
 
 /// CreateTargetMachine - Create the TargetMachine we will generate code with.





More information about the llvm-commits mailing list