From d6e84b3ed8ed5e0a3e16959abe23a876de13c314 Mon Sep 17 00:00:00 2001 From: "kenton@google.com" Date: Tue, 22 Dec 2009 19:43:41 +0000 Subject: When serializing to an ostream, verify that there were no stream-level errors before returning success. --- src/google/protobuf/message.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/google/protobuf/message.cc') diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 09166f3a..91e6878e 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -168,8 +168,11 @@ bool Message::SerializePartialToFileDescriptor(int file_descriptor) const { } bool Message::SerializeToOstream(ostream* output) const { - io::OstreamOutputStream zero_copy_output(output); - return SerializeToZeroCopyStream(&zero_copy_output); + { + io::OstreamOutputStream zero_copy_output(output); + if (!SerializeToZeroCopyStream(&zero_copy_output)) return false; + } + return output->good(); } bool Message::SerializePartialToOstream(ostream* output) const { -- cgit v1.2.3