diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/util.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/util.cc b/src/util.cc index a030ecb0..f5a15944 100644 --- a/src/util.cc +++ b/src/util.cc @@ -265,14 +265,13 @@ dcp::file_to_string (boost::filesystem::path p, uintmax_t max_length) throw FileError ("could not open file", p, errno); } - char* c = new char[len]; + std::vector<char> buffer(len); /* This may read less than `len' if we are on Windows and we have CRLF in the file */ - int const N = f.read(c, 1, len); + int const N = f.read(buffer.data(), 1, len); + return string(buffer.data(), N); +} - string s (c, N); - delete[] c; - return s; } |
