projects
/
libdcp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7c96eea
)
Hopefully fix file_to_string() on Windows with text files.
author
Carl Hetherington
<cth@carlh.net>
Wed, 4 Nov 2015 21:25:36 +0000
(21:25 +0000)
committer
Carl Hetherington
<cth@carlh.net>
Wed, 4 Nov 2015 21:25:36 +0000
(21:25 +0000)
src/util.cc
patch
|
blob
|
history
diff --git
a/src/util.cc
b/src/util.cc
index 5a5db98d87e215702c344508081f0ceacba1fb7b..856bc9bd0001d0d958cbae4334df0824b6cc0a25 100644
(file)
--- 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;