diff options
author | Greg Clayton <gclayton@apple.com> | 2012-01-06 02:01:06 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-01-06 02:01:06 +0000 |
commit | 4017fa399b0018a08bf6ae81fcb6900848034a6f (patch) | |
tree | fa20a55c9b42182c5a3ba150989e484958201173 /lldb/source/Host/common/FileSpec.cpp | |
parent | 8e2fc5c5e997b21721b91d97e6b12ce40e5d5791 (diff) | |
download | bcm5719-llvm-4017fa399b0018a08bf6ae81fcb6900848034a6f.tar.gz bcm5719-llvm-4017fa399b0018a08bf6ae81fcb6900848034a6f.zip |
<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
llvm-svn: 147646
Diffstat (limited to 'lldb/source/Host/common/FileSpec.cpp')
-rw-r--r-- | lldb/source/Host/common/FileSpec.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp index 1f0942d5bb5..f769d2e39f9 100644 --- a/lldb/source/Host/common/FileSpec.cpp +++ b/lldb/source/Host/common/FileSpec.cpp @@ -771,13 +771,13 @@ FileSpec::MemorySize() const 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 @@ FileSpec::ReadFileContents (off_t file_offset, void *dst, size_t dst_len) const 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 @@ FileSpec::ReadFileContents (off_t file_offset, void *dst, size_t dst_len) const // 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; } |