[Lldb-commits] [PATCH] Fix TestDataFormatter* on Linux

Vince Harron vharron at google.com
Sun Feb 15 17:51:38 PST 2015


Hi clayborg,

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.

http://reviews.llvm.org/D7658

Files:
  source/Core/FormatEntity.cpp

Index: source/Core/FormatEntity.cpp
===================================================================
--- source/Core/FormatEntity.cpp
+++ source/Core/FormatEntity.cpp
@@ -950,11 +950,11 @@
             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());

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7658.19997.patch
Type: text/x-patch
Size: 861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150216/604c04d1/attachment.bin>


More information about the lldb-commits mailing list