Fix error handling in fmt::fprintf.

This commit is contained in:
Victor Zverovich
2014-11-14 09:40:01 -08:00
parent 8ea9f068c7
commit 615c1eef6b
2 changed files with 9 additions and 1 deletions
+2 -1
View File
@@ -1087,7 +1087,8 @@ void fmt::print_colored(Color c, StringRef format, ArgList args) {
int fmt::fprintf(std::FILE *f, StringRef format, ArgList args) {
MemoryWriter w;
printf(w, format, args);
return std::fwrite(w.data(), 1, w.size(), f);
std::size_t size = w.size();
return std::fwrite(w.data(), 1, size, f) < size ? -1 : static_cast<int>(size);
}
// Explicit instantiations for char.