diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/util.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util.cc b/src/util.cc index 5a5db98d..856bc9bd 100644 --- a/src/util.cc +++ b/src/util.cc @@ -408,12 +408,12 @@ 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 + 1]; - fread (c, 1, len, f); + char* c = new char[len]; + /* This may read less than `len' if we are on Windows and we have CRLF in the file */ + int const N = fread (c, 1, len, f); fclose (f); - c[len] = '\0'; - string s (c); + string s (c, N); delete[] c; return s; |
