Skip to content

Commit

Permalink
Destruct CodedOutputStream instead of using Trim()
Browse files Browse the repository at this point in the history
  • Loading branch information
mpartel authored and acozzette committed Feb 12, 2020
1 parent f6902d6 commit 82a0575
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/google/protobuf/compiler/command_line_interface.cc
Expand Up @@ -2229,17 +2229,19 @@ bool CommandLineInterface::WriteDescriptorSet(

io::FileOutputStream out(fd);

io::CodedOutputStream coded_out(&out);
// Determinism is useful here because build outputs are sometimes checked
// into version control.
coded_out.SetSerializationDeterministic(true);
if (!file_set.SerializeToCodedStream(&coded_out)) {
std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno())
<< std::endl;
out.Close();
return false;
{
io::CodedOutputStream coded_out(&out);
// Determinism is useful here because build outputs are sometimes checked
// into version control.
coded_out.SetSerializationDeterministic(true);
if (!file_set.SerializeToCodedStream(&coded_out)) {
std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno())
<< std::endl;
out.Close();
return false;
}
}
coded_out.Trim();

if (!out.Close()) {
std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno())
<< std::endl;
Expand Down

0 comments on commit 82a0575

Please sign in to comment.