[Lldb-commits] [lldb] r116963 - in /lldb/trunk: include/lldb/Core/FileSpec.h source/Core/FileSpec.cpp

Greg Clayton gclayton at apple.com
Wed Oct 20 15:52:05 PDT 2010


Author: gclayton
Date: Wed Oct 20 17:52:05 2010
New Revision: 116963

URL: http://llvm.org/viewvc/llvm-project?rev=116963&view=rev
Log:
Fixed a crasher that could happen if a FileSpec had a filename only, or vice
versa.


Modified:
    lldb/trunk/include/lldb/Core/FileSpec.h
    lldb/trunk/source/Core/FileSpec.cpp

Modified: lldb/trunk/include/lldb/Core/FileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=116963&r1=116962&r2=116963&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Core/FileSpec.h Wed Oct 20 17:52:05 2010
@@ -462,8 +462,11 @@
     ///
     /// @param[out] lines
     ///     The string array into which to read the file.
+    ///
+    /// @result
+    ///     Returns the number of lines that were read from the file.
     //------------------------------------------------------------------
-    bool
+    size_t
     ReadFileLines (STLStringArray &lines);
 
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Core/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=116963&r1=116962&r2=116963&view=diff
==============================================================================
--- lldb/trunk/source/Core/FileSpec.cpp (original)
+++ lldb/trunk/source/Core/FileSpec.cpp Wed Oct 20 17:52:05 2010
@@ -732,25 +732,21 @@
     return data_sp;
 }
 
-bool
+size_t
 FileSpec::ReadFileLines (STLStringArray &lines)
 {
-    bool ret_val = false;
     lines.clear();
-
-    std::string dir_str (m_directory.AsCString());
-    std::string file_str (m_filename.AsCString());
-    std::string full_name = dir_str + "/" + file_str;
-
-    ifstream file_stream (full_name.c_str());
-
-    if (file_stream)
+    char path[PATH_MAX];
+    if (GetPath(path, sizeof(path)))
     {
-        std::string line;
-        while (getline (file_stream, line))
-          lines.push_back (line);
-        ret_val = true;
-    }
+        ifstream file_stream (path);
 
-    return ret_val;
+        if (file_stream)
+        {
+            std::string line;
+            while (getline (file_stream, line))
+                lines.push_back (line);
+        }
+    }
+    return lines.size();
 }





More information about the lldb-commits mailing list