<rdar://problem/10652336>
Fixed a crasher when trying to load an expression prefix file:
% touch /tmp/carp.txt
% xcrun lldb
(lldb) settings set target.expr-prefix /tmp/carp.txt
Segmentation fault
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@147646 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Host/common/FileSpec.cpp b/source/Host/common/FileSpec.cpp
index 1f0942d..f769d2e 100644
--- a/source/Host/common/FileSpec.cpp
+++ b/source/Host/common/FileSpec.cpp
@@ -771,13 +771,13 @@
size_t
-FileSpec::ReadFileContents (off_t file_offset, void *dst, size_t dst_len) const
+FileSpec::ReadFileContents (off_t file_offset, void *dst, size_t dst_len, Error *error_ptr) const
{
+ Error error;
size_t bytes_read = 0;
char resolved_path[PATH_MAX];
if (GetPath(resolved_path, sizeof(resolved_path)))
{
- Error error;
File file;
error = file.Open(resolved_path, File::eOpenOptionRead);
if (error.Success())
@@ -787,6 +787,12 @@
error = file.Read(dst, bytes_read, file_offset_after_seek);
}
}
+ else
+ {
+ error.SetErrorString("invalid file specification");
+ }
+ if (error_ptr)
+ *error_ptr = error;
return bytes_read;
}
@@ -802,18 +808,24 @@
// verified using the DataBuffer::GetByteSize() function.
//------------------------------------------------------------------
DataBufferSP
-FileSpec::ReadFileContents (off_t file_offset, size_t file_size) const
+FileSpec::ReadFileContents (off_t file_offset, size_t file_size, Error *error_ptr) const
{
+ Error error;
DataBufferSP data_sp;
char resolved_path[PATH_MAX];
if (GetPath(resolved_path, sizeof(resolved_path)))
{
- Error error;
File file;
error = file.Open(resolved_path, File::eOpenOptionRead);
if (error.Success())
error = file.Read (file_size, file_offset, data_sp);
}
+ else
+ {
+ error.SetErrorString("invalid file specification");
+ }
+ if (error_ptr)
+ *error_ptr = error;
return data_sp;
}