[Lldb-commits] [lldb] r229767 - Fix TestDataFormatter* on Linux

Vince Harron vharron at google.com
Wed Feb 18 15:16:53 PST 2015


Author: vharron
Date: Wed Feb 18 17:16:51 2015
New Revision: 229767

URL: http://llvm.org/viewvc/llvm-project?rev=229767&view=rev
Log:
Fix TestDataFormatter* on Linux

llvm::StringRef doesn't make a copy of a string, it just holds a
reference. When special_directions_stream went out of scope,
special_directions was holding on to a stale pointer.

Moving special_directions_stream into a higher scope to keep
special_directions pointing to a valid string.


Modified:
    lldb/trunk/source/Core/FormatEntity.cpp

Modified: lldb/trunk/source/Core/FormatEntity.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatEntity.cpp?rev=229767&r1=229766&r2=229767&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatEntity.cpp (original)
+++ lldb/trunk/source/Core/FormatEntity.cpp Wed Feb 18 17:16:51 2015
@@ -950,11 +950,11 @@ DumpValue (Stream &s,
             return false;
         if (log)
             log->Printf("[Debugger::FormatPrompt] handle as array");
+        StreamString special_directions_stream;
         llvm::StringRef special_directions;
         if (close_bracket_index != llvm::StringRef::npos && subpath.size() > close_bracket_index)
         {
             ConstString additional_data (subpath.drop_front(close_bracket_index+1));
-            StreamString special_directions_stream;
             special_directions_stream.Printf("${%svar%s",
                                              do_deref_pointer ? "*" : "",
                                              additional_data.GetCString());





More information about the lldb-commits mailing list