Fixed a problem where the target didn't use a
NULL-terminated C string to store the contents
of the expression prefix file.  This meant that
expressions, when printing the contents of the
prefix into the expression's text, would
invariably put in bad data after the end of the
expression.

Now, instead, we store the prefix contents in a
std::string, which handles null-termination
correctly.

llvm-svn: 144760
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 022cdb3..e06f115 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1430,8 +1430,8 @@
 const char *
 Target::GetExpressionPrefixContentsAsCString ()
 {
-    if (m_expr_prefix_contents_sp)
-        return (const char *)m_expr_prefix_contents_sp->GetBytes();
+    if (!m_expr_prefix_contents.empty())
+        return m_expr_prefix_contents.c_str();
     return NULL;
 }
 
@@ -2160,7 +2160,7 @@
 ) :
     InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance),
     m_expr_prefix_file (),
-    m_expr_prefix_contents_sp (),
+    m_expr_prefix_contents (),
     m_prefer_dynamic_value (2),
     m_skip_prologue (true, true),
     m_source_map (NULL, NULL),
@@ -2198,7 +2198,7 @@
 TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rhs) :
     InstanceSettings (*Target::GetSettingsController(), CreateInstanceName().AsCString()),
     m_expr_prefix_file (rhs.m_expr_prefix_file),
-    m_expr_prefix_contents_sp (rhs.m_expr_prefix_contents_sp),
+    m_expr_prefix_contents (rhs.m_expr_prefix_contents),
     m_prefer_dynamic_value (rhs.m_prefer_dynamic_value),
     m_skip_prologue (rhs.m_skip_prologue),
     m_source_map (rhs.m_source_map),
@@ -2231,7 +2231,7 @@
     if (this != &rhs)
     {
         m_expr_prefix_file = rhs.m_expr_prefix_file;
-        m_expr_prefix_contents_sp = rhs.m_expr_prefix_contents_sp;
+        m_expr_prefix_contents = rhs.m_expr_prefix_contents;
         m_prefer_dynamic_value = rhs.m_prefer_dynamic_value;
         m_skip_prologue = rhs.m_skip_prologue;
         m_source_map = rhs.m_source_map;
@@ -2280,17 +2280,19 @@
                         return;
                     }
             
-                    m_expr_prefix_contents_sp = m_expr_prefix_file.GetCurrentValue().ReadFileContents();
-            
-                    if (!m_expr_prefix_contents_sp && m_expr_prefix_contents_sp->GetByteSize() == 0)
+                    DataBufferSP file_contents = m_expr_prefix_file.GetCurrentValue().ReadFileContents();
+                    
+                    if (!file_contents && file_contents->GetByteSize() == 0)
                     {
                         err.SetErrorStringWithFormat ("couldn't read data from '%s'", value);
-                        m_expr_prefix_contents_sp.reset();
+                        m_expr_prefix_contents.clear();
                     }
+                    
+                    m_expr_prefix_contents.assign((const char*)file_contents->GetBytes(), file_contents->GetByteSize());
                 }
                 break;
             case eVarSetOperationClear:
-                m_expr_prefix_contents_sp.reset();
+                m_expr_prefix_contents.clear();
             }
         }
     }