Merge pull request #530 from protocolbuffers/memory_leak

Fix memory leak
pull/13171/head
Joshua Haberman 3 years ago committed by GitHub
commit c16539bb55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      upbc/protoc-gen-upb.cc
  2. 8
      upbc/protoc-gen-upbdefs.cc

@ -1493,10 +1493,14 @@ bool Generator::Generate(const protobuf::FileDescriptor* file,
}
}
Output h_output(context->Open(HeaderFilename(file)));
std::unique_ptr<protobuf::io::ZeroCopyOutputStream> h_output_stream(
context->Open(HeaderFilename(file)));
Output h_output(h_output_stream.get());
WriteHeader(file, h_output);
Output c_output(context->Open(SourceFilename(file)));
std::unique_ptr<protobuf::io::ZeroCopyOutputStream> c_output_stream(
context->Open(SourceFilename(file)));
Output c_output(c_output_stream.get());
WriteSource(file, c_output, fasttable_enabled);
return true;

@ -170,10 +170,14 @@ bool Generator::Generate(const protobuf::FileDescriptor* file,
return false;
}
Output h_def_output(context->Open(DefHeaderFilename(file->name())));
std::unique_ptr<protobuf::io::ZeroCopyOutputStream> h_output_stream(
context->Open(DefHeaderFilename(file->name())));
Output h_def_output(h_output_stream.get());
WriteDefHeader(file, h_def_output);
Output c_def_output(context->Open(DefSourceFilename(file->name())));
std::unique_ptr<protobuf::io::ZeroCopyOutputStream> c_output_stream(
context->Open(DefSourceFilename(file->name())));
Output c_def_output(c_output_stream.get());
WriteDefSource(file, c_def_output);
return true;

Loading…
Cancel
Save