From 0b0b512fd6eaa15626d0b1caad24ae66a79e8408 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Thu, 30 Aug 2012 18:15:10 +0000 Subject: OptionValueFileSpec had an accessor to read the contents of the file and return the data. This can end up being used to get the string contents of a text file and could end up not being NULL terminated. I added accessors to get the file contents raw, or with a null terminator. Added the needed calls to make this happen in the FileSpec and File classes. llvm-svn: 162921 --- lldb/source/Host/common/File.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lldb/source/Host/common/File.cpp') diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index a84266f7110..ca0c223e629 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -538,7 +538,7 @@ File::Read (void *buf, size_t &num_bytes, off_t &offset) } Error -File::Read (size_t &num_bytes, off_t &offset, DataBufferSP &data_buffer_sp) +File::Read (size_t &num_bytes, off_t &offset, bool null_terminate, DataBufferSP &data_buffer_sp) { Error error; @@ -557,7 +557,7 @@ File::Read (size_t &num_bytes, off_t &offset, DataBufferSP &data_buffer_sp) num_bytes = bytes_left; std::auto_ptr data_heap_ap; - data_heap_ap.reset(new DataBufferHeap(num_bytes, '\0')); + data_heap_ap.reset(new DataBufferHeap(num_bytes + (null_terminate ? 1 : 0), '\0')); if (data_heap_ap.get()) { -- cgit v1.2.3