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}
diff --git a/webrtc/system_wrappers/source/file_impl.cc b/webrtc/system_wrappers/source/file_impl.cc
index 0ee0dea..e033c0e 100644
--- a/webrtc/system_wrappers/source/file_impl.cc
+++ b/webrtc/system_wrappers/source/file_impl.cc
@@ -243,13 +243,12 @@
}
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() {