aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2017-12-13 13:06:29 -0800
committerJisi Liu <jisi.liu@gmail.com>2017-12-13 13:06:29 -0800
commit6b01e6440cdac325bc131ec6713eab9d8307414a (patch)
tree852e8725e4e422cdf64788f841cf2f31eb87874e
parentf69a5db66f170b22b8a5a0abc04ee65d11ef2621 (diff)
downloadprotobuf-6b01e6440cdac325bc131ec6713eab9d8307414a.tar.gz
protobuf-6b01e6440cdac325bc131ec6713eab9d8307414a.tar.bz2
protobuf-6b01e6440cdac325bc131ec6713eab9d8307414a.zip
Explicitly propagate the status of Flush().
Before the change, an implicit Flush() will be triggered in the destructor of the input stream. However, the return code of Flush() is not discarded. This change makes sure when Flush() fails, we will return false.
-rw-r--r--src/google/protobuf/message.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc
index a0d3feba..42ec0337 100644
--- a/src/google/protobuf/message.cc
+++ b/src/google/protobuf/message.cc
@@ -170,12 +170,12 @@ size_t Message::SpaceUsedLong() const {
bool Message::SerializeToFileDescriptor(int file_descriptor) const {
io::FileOutputStream output(file_descriptor);
- return SerializeToZeroCopyStream(&output);
+ return SerializeToZeroCopyStream(&output) && output.Flush();
}
bool Message::SerializePartialToFileDescriptor(int file_descriptor) const {
io::FileOutputStream output(file_descriptor);
- return SerializePartialToZeroCopyStream(&output);
+ return SerializePartialToZeroCopyStream(&output) && output.Flush();
}
bool Message::SerializeToOstream(std::ostream* output) const {