Handle searching files that end with an incomplete UTF-8 sequence

Previously this would cause infinite looping as we tried to read more to complete the UTF-8 sequence.
This commit is contained in:
Allan Odgaard
2015-01-21 15:55:16 +07:00
parent 49b784f09c
commit f9cef6959b

View File

@@ -115,6 +115,9 @@ namespace file
ssize_t len = read(_fd, &buf.front(), buf.size());
buf.resize(len < 0 ? 0 : len);
if(len == 0 && !utf8::is_valid(_spillover.begin(), _spillover.end()))
_spillover = "\uFFFD";
buf.insert(buf.begin(), _spillover.begin(), _spillover.end());
_spillover.clear();