diff options
author | Daniel Malea <daniel.malea@intel.com> | 2013-08-06 21:40:08 +0000 |
---|---|---|
committer | Daniel Malea <daniel.malea@intel.com> | 2013-08-06 21:40:08 +0000 |
commit | a984aa968d40e16e6fe2d53bb0eb64a54964f439 (patch) | |
tree | 6f573c24b2b10dc54cb0bad9b61825ff918343e1 | |
parent | e0d9e7543b684ffedabc9b39f4e4910eb975099e (diff) | |
download | lldb-a984aa968d40e16e6fe2d53bb0eb64a54964f439.tar.gz |
Fix bug in Host::getLLDBPath() due to misusing Twine
- use SmallString instead
- original implementation resulted in incorrect behaviour of lldb -P
Fix by Kal Conley!
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@187818 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | source/Host/common/Host.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp index 2e5b6e98f..a7bad0063 100644 --- a/source/Host/common/Host.cpp +++ b/source/Host/common/Host.cpp @@ -53,9 +53,10 @@ #include "lldb/Target/Process.h" #include "lldb/Target/TargetList.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/Host.h" #include "llvm/Support/MachO.h" -#include "llvm/ADT/Twine.h" +#include "llvm/Support/raw_ostream.h" @@ -1031,17 +1032,15 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec) ::strncpy (framework_pos, "/Resources/Python", PATH_MAX - (framework_pos - raw_path)); } #else - llvm::Twine python_version_dir; - python_version_dir = "/python" - + llvm::Twine(PY_MAJOR_VERSION) - + "." - + llvm::Twine(PY_MINOR_VERSION) - + "/site-packages"; + llvm::SmallString<256> python_version_dir; + llvm::raw_svector_ostream os(python_version_dir); + os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << "/site-packages"; + os.flush(); // We may get our string truncated. Should we protect // this with an assert? - ::strncat(raw_path, python_version_dir.str().c_str(), + ::strncat(raw_path, python_version_dir.c_str(), sizeof(raw_path) - strlen(raw_path) - 1); #endif |