onlineupdate/source/update/updater/updater.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
New commits: commit 1bc6f5868fd5e780e70f999144432f30d8f64149 Author: Muhammet Kara <[email protected]> AuthorDate: Sun Feb 16 21:12:10 2020 +0300 Commit: Muhammet Kara <[email protected]> CommitDate: Sun Feb 16 22:32:47 2020 +0100 Proper error check for fwrite in updater.cxx A less-than-zero check for an unsigned value of type size_t doesn't make sense, and: If the return value of fwrite differs from the count parameter, it means that a writing error prevented the function from completing. In this case, the error indicator (ferror) will be set for the stream. Change-Id: I344e608b2bc03a4a117fc5cca1acb8e26eda247a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88817 Tested-by: Jenkins Reviewed-by: Muhammet Kara <[email protected]> diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx index 006e2ffe5a94..54750afb4218 100644 --- a/onlineupdate/source/update/updater/updater.cxx +++ b/onlineupdate/source/update/updater/updater.cxx @@ -731,8 +731,9 @@ static int ensure_copy(const NS_tchar *path, const NS_tchar *dest) while (written < read) { - size_t chunkWritten = fwrite(buffer, 1, read - written, outfile); - if (chunkWritten <= 0) + size_t nCount = read - written; + size_t chunkWritten = fwrite(buffer, 1, nCount, outfile); + if (chunkWritten != nCount) { LOG(("ensure_copy: failed to write the file: " LOG_S ", err: %d", dest, errno)); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
