From 6b1968ea70fc69da04aa49b0a5305cda51d66d38 Mon Sep 17 00:00:00 2001 From: terelius Date: Tue, 29 Mar 2016 01:39:59 -0700 Subject: [PATCH] Allow passing in strings of length zero to FileWrapper::Write without closing the file. BUG=webrtc:5253 Review URL: https://codereview.webrtc.org/1714503003 Cr-Commit-Position: refs/heads/master@{#12132} --- webrtc/system_wrappers/source/file_impl.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/webrtc/system_wrappers/source/file_impl.cc b/webrtc/system_wrappers/source/file_impl.cc index 0ee0deab6c..e033c0eb73 100644 --- a/webrtc/system_wrappers/source/file_impl.cc +++ b/webrtc/system_wrappers/source/file_impl.cc @@ -243,13 +243,12 @@ bool FileWrapperImpl::Write(const void* buf, size_t length) { } size_t num_bytes = fwrite(buf, 1, length, id_); - if (num_bytes > 0) { - size_in_bytes_ += num_bytes; - return true; + size_in_bytes_ += num_bytes; + if (num_bytes != length) { + CloseFileImpl(); + return false; } - - CloseFileImpl(); - return false; + return true; } int FileWrapperImpl::CloseFileImpl() {