From a595c3ba856d9e92dceaa1cb102585fcf540e9d6 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 10 Apr 2017 19:29:35 -0700 Subject: [PATCH] Use fwrite return value in file_body --- CHANGELOG.md | 1 + examples/file_body.hpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dade117..9b07a343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ 1.0.0-b33 * Require Visual Studio 2015 Update 3 or later +* Use fwrite return value in file_body -------------------------------------------------------------------------------- diff --git a/examples/file_body.hpp b/examples/file_body.hpp index aa88ce2f..00f2b543 100644 --- a/examples/file_body.hpp +++ b/examples/file_body.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -74,15 +75,17 @@ struct file_body size_ - offset_); else buf_len_ = sizeof(buf_); - auto const nread = fread(buf_, 1, sizeof(buf_), file_); + auto const nread = fread( + buf_, 1, sizeof(buf_), file_); if(ferror(file_)) { ec = error_code(errno, system_category()); return true; } - offset_ += buf_len_; - wf(boost::asio::buffer(buf_, buf_len_)); + BOOST_ASSERT(nread != 0); + offset_ += nread; + wf(boost::asio::buffer(buf_, nread)); return offset_ >= size_; } };